spc_request()


邀请向智能扩展板传送命令

Description

string spc_request(int $sid, int $addr, string $msg, string $opt = "")

Parameters

Return Value

根据命令的智能扩展板的应答,CSV(comma-separated values)形态的字符串

Example

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);
}

See also