Inter Frame Delimiter


The command to set inter frame delimiter is ifd. While receiving data, PES-2407 distinguishes frames with the designated delimiter by this command. At this time, you can check the frame length with "get rxlen" command and receive data in frame units.

Setting inter frame delimiter

Unsetting inter frame delimiter

How to unset inter frame delimiter is as follows:

"set ifd"

If you do not specify anything after the ifd command as above, the frame delimiter is unset.

<?php
include "lib/sd_spc.php";

$sid = 14;

spc_reset();
spc_sync_baud(115200);

spc_request_dev($sid, "set uart 115200");

spc_request_dev($sid, "set ifd 1b01");
echo spc_request_dev($sid, "get ifd"), "\r\n";  // output: 1b01

spc_request_dev($sid, "set ifd 1b02 1b03");
echo spc_request_dev($sid, "get ifd"), "\r\n";  // output: 1b02 1b03

spc_request_dev($sid, "set ifd");
echo spc_request_dev($sid, "get ifd"), "\r\n";  // output:
?>
<?php
include "/lib/sd_spc.php";

$rwbuf = "";
$sid = 14;
spc_reset();
spc_sync_baud(115200);

spc_request_dev($sid, "set uart 115200N81");
spc_request_dev($sid, "set ifd 0d");

while(1)
{
    $txfree = (int)spc_request_dev($sid, "get txfree");
    $rlen = (int)spc_request_dev($sid, "get rxlen");
    if($rlen > 0)
    {
        if($rlen <= $txfree)
        {
            // receive data
            $rwbuf = spc_request($sid, 6, "$rlen");

            // send data
            spc_request($sid, 7, $rwbuf);

            // print data
            echo $rwbuf;
        }
    }
    usleep(1000);
}
?>

※ Note: The setting of inter frame delimiter ("set ifd") and the setting of inter frame gap ("set ifg") cannot be used at the same time.