监视输入端口


呼出为了输入端口监视的spc_request函数

spc_request($sid, 4, $cmd);

命令构造如下。

"get $port input"

返还值

正常的返还值如下。

"200,$state"

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

// get status of input ports
echo "Port 0: ", spc_request($sid, 4, "get 0 input"), "\r\n";
echo "Port 1: ", spc_request($sid, 4, "get 1 input"), "\r\n";
echo "Port 2: ", spc_request($sid, 4, "get 2 input"), "\r\n";
echo "Port 3: ", spc_request($sid, 4, "get 3 input"), "\r\n";
/*
output example
Port 0: 200,0
Port 1: 200,1
Port 2: 200,1
Port 3: 200,0
*/
?>