2017-02-18 17:38:55 +00:00
|
|
|
#!/usr/bin/php
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once __DIR__.'/../../include/php/const';
|
|
|
|
require_once __DIR__.'/Pin.php';
|
|
|
|
|
|
|
|
function gpio_low($pin){
|
|
|
|
|
|
|
|
/* (1) Create GPIO Pin instance */
|
|
|
|
try{
|
|
|
|
|
|
|
|
$gpio = new Pin($pin);
|
|
|
|
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
|
|
|
return 127;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* (2) Set mode to in */
|
|
|
|
$gpio->value = Pin::GPIO_LOW;
|
|
|
|
|
2017-02-18 17:49:04 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-02-18 17:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* [1] Check argument
|
|
|
|
=========================================================*/
|
|
|
|
if( $argc < 2 || !preg_match('@^\d+$@', $argv[1]) ){
|
|
|
|
echo 127;
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* [2] Launch main script
|
|
|
|
=========================================================*/
|
|
|
|
echo gpio_low($argv[1]);
|
|
|
|
?>
|
|
|
|
|