spc_request()


request sending a command to smart expansion boards

Description

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

Parameters

Return Value

a response string in CSV format from smart expansion boards on success, false on failure

※ CSV : Comma-Separated Values

Example

<?php
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