spc_request_dev($sid, $cmd);
Structure of a command string is as follows:
"get $port output"
The normal return value is in string form and is as follows:
value | description |
---|---|
0 | OFF |
1 | ON |
<?php
include "/lib/sd_spc.php";
spc_reset();
spc_sync_baud();
$sid = 1;
echo "turn all output ports on\r\n";
spc_request_dev($sid, "set 0 output high");
spc_request_dev($sid, "set 1 output high");
spc_request_dev($sid, "set 2 output high");
spc_request_dev($sid, "set 3 output high");
// get status of output ports
echo "Port 0: ", spc_request_dev($sid, "get 0 output"), "\r\n";
echo "Port 1: ", spc_request_dev($sid, "get 1 output"), "\r\n";
echo "Port 2: ", spc_request_dev($sid, "get 2 output"), "\r\n";
echo "Port 3: ", spc_request_dev($sid, "get 3 output"), "\r\n";
sleep(1);
echo "turn all output ports off\r\n";
spc_request_dev($sid, "set 0 output low");
spc_request_dev($sid, "set 1 output low");
spc_request_dev($sid, "set 2 output low");
spc_request_dev($sid, "set 3 output low");
// get status of output ports
echo "Port 0: ", spc_request_dev($sid, "get 0 output"), "\r\n";
echo "Port 1: ", spc_request_dev($sid, "get 1 output"), "\r\n";
echo "Port 2: ", spc_request_dev($sid, "get 2 output"), "\r\n";
echo "Port 3: ", spc_request_dev($sid, "get 3 output"), "\r\n"
?>
turn all output ports on
Port 0: 1
Port 1: 1
Port 2: 1
Port 3: 1
turn all output ports off
Port 0: 0
Port 1: 0
Port 2: 0
Port 3: 0