spc_request_dev()


request sending a device command to smart expansion boards

Description

string spc_request_dev(int $sid, string $cmd)

Parameters

Return Value

a response string according to each command

Example

<?php
/* This example is for PES-2403 only */
include_once "/lib/sd_spc.php";

spc_reset();
spc_sync_baud(460800);

$sid = 1;
spc_request_dev($sid, "set mode full");
spc_request_dev($sid, "set vref stop 2");
spc_request_dev($sid, "set vref drive 8");
spc_request_dev($sid, "set speed 400");
spc_request_dev($sid, "set accel 800");
spc_request_dev($sid, "set rsnc 120 250");

$state = 0;
spc_request_dev($sid, "move 400");
while($state = (int)spc_request_dev($sid, "get state"))
{
  echo "state: $state\r\n";
  usleep(200000);
}
echo "state: $state\r\n";
?>

See also