I tried running the sample code provided oin the PSP Library Reference under spc_request() and I get the error PHP error: undefined offset '1' in file relay.php on line 20. Can anyone provide any insight as to why I'm getting this error? I'm using a Blue P4S-342 with the PES-2401N relay board.
<?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);
}
?>
<?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);
}
?>
Comment