Inter Frame Gap


The command to set inter frame gap is ifg.

"set ifg (bits)"

Specify a interval to bits.

The inter frame gap is a way to distinguish frames using time. The interval can be set from 0 to 30000 in bit unit. For example, if you set the frame interval to 10 at 9600 bps, the actual setup time will be about 0.001 seconds (= 10/9600). Even if the unit is set to the same value, the set time differs if the communication speed is different.

In the case of transmitting data

The transmitted frames are transmitted at the set frame interval.

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

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

spc_request_dev($sid, "set uart 115200N81");
// set frame to frame interval : 100 milliseconds
spc_request_dev($sid, "set ifg 11520");

spc_request($sid, 7, "This is the first frame.\r\n");
spc_request($sid, 7, "This is the second frame.\r\nIt will be transmitted 100 milliseconds later right after the first packet has been transmitted. \r\n");
?>

In the case of receiving data

If there is no new data until the set time while receiving the data, the data received up to that point is recognized as one frame. At this time, you can check the frame length with "get rxlen" command and receive data in frame units.

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

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

spc_request_dev($sid, "set uart 115200N81");
// set frame to frame interval : 100 milliseconds
spc_request_dev($sid, "set ifg 11520");

while(1)
{
    $rlen = (int)spc_request_dev($sid, "get rxlen");
    if($rlen > 0)
    {
        $rbuf = spc_request($sid, 6, "$rlen");
        echo "frame length = $rlen\r\n";
        hexdump($rbuf);
    }
}
?>

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