request sending a command to smart expansion boards
string/bool spc_request(int $sid, int $addr, string $msg, string $opt = "")
a response string in CSV format from smart expansion boards on success, false on failure
※ CSV : Comma-Separated Values
<?php
include_once "/lib/sd_spc.php";
spc_reset();
spc_sync_baud();
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);
}
?>