邀请向智能扩展板传送命令
string spc_request(int $sid, int $addr, string $msg, string $opt = "")
根据命令的智能扩展板的应答,CSV(comma-separated values)形态的字符串
include_once "/lib/sd_spc.php";
spc_reset();
spc_sync_baud(115200);
spc_scan();
$sid = 1;
function eio_in($sid, $pin)
{
$resp = spc_request($sid, 4, "get $pin input");
if($resp === false)
return "";
$resp = explode(",", $resp);
return $resp[1];
}
while(1)
{
echo eio_in($sid, 0);
echo eio_in($sid, 1);
echo eio_in($sid, 2);
echo eio_in($sid, 3);
echo "\r\n";
sleep(1);
}