The command to get the free space in send buffer is txfree.
"get txfree"
The response value is a string in integer form.
an example of getting the free space in send buffer
This example receives data from the serial port and send it back to the same port.
<?php
include "/lib/sd_spc.php";
$rwbuf = "";
$sid = 14;
spc_reset();
spc_sync_baud(115200);
spc_request_dev($sid, "set uart 115200N81");
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);
}
?>