When you "write" to the serial port, you are really writing to a circular 
buffer.  Then the OS will start moving the data from the buffer to the 
hardware serial peripheral, when "it gets around to it."
The "latency" is in the OS.

So, you could re-write the kernel driver to respond faster, or write a PRU 
driver that did not depend on the OS to "get around to it."

The easiest thing to reduce total latency is to just run the serial port 
faster.  The OS overhead would remain the same, but the underlying transfer 
rate could be improved by a factor of 2 or 4 or ... .

--- Graham

==

On Thursday, February 2, 2017 at 6:38:01 AM UTC-6, [email protected] wrote:
>
> I have written a simple program that writes into the serial port 
> (blockingly) and measures the time it takes. writing 104 Bytes of data @ 
> 19200 takes 58/59 msec.
>
> Reading the same amount of data takes only 54 msec (making a simple math 
> shows that 54 msec is the correct number).
>
> How can i reduce the latency of writing into the serialport?? By the way 
> my hardware is a Beagle Bone Black. My code follows:
>
> QTime t;t.start();
> int bytes_written = write(m_serialport_fd, data, data_size);
> if(bytes_written != data_size)
>    //handle error
> tcdrain(m_serialport_fd);
> qDebug()<<"Writing into serialport took" << t.elapsed();
>
> Any hints is appreciated.
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/be9b9aca-e67a-4027-9aa3-b28595832c68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to