Monitoring Input Ports


Calling spc_request_dev function for monitoring input ports

spc_request_dev($sid, $cmd);

Structure of a command string is as follows:

"get $port input"

Return Value

The normal return value is in string form and is as follows:

value description
0 OFF
1 ON

Example

<?php
include "/lib/sd_spc.php";
spc_reset();
spc_sync_baud(115200);
$sid = 1;

// get status of input ports
echo "Port 0: ", spc_request_dev($sid, "get 0 input"), "\r\n";
echo "Port 1: ", spc_request_dev($sid, "get 1 input"), "\r\n";
echo "Port 2: ", spc_request_dev($sid, "get 2 input"), "\r\n";
echo "Port 3: ", spc_request_dev($sid, "get 3 input"), "\r\n";
?>

output (example)

Port 0: 0
Port 1: 1
Port 2: 0
Port 3: 1