[yocto] FW: [meta-freescale] serial port timeout before expected # of bytes arrives

Thanassis Silis djnass_18 at hotmail.com
Thu Jul 4 07:24:50 PDT 2013



From: djnass_18 at hotmail.com
To: meta-freescale at yoctoproject.org
Date: Thu, 4 Jul 2013 13:40:10 +0000
Subject: [meta-freescale] serial port timeout before expected # of bytes	arrives




Hello everyone,
I am trying to port an application that is receiving/sending data through the serial port. 
On the sabrelite board that is the /dev/ttymxc0 port, ie the 2ndary serial port (the primary being /dev/ttymxc1).

I am using the functions select() and read() to read from the serial port , in order to implement a timeout mechanism that is waiting for a few seconds for bytes to arrive and if should they not arrive, then the timeout is reached.

The receiving loop works like this:
I wait for 2 bytes - the opcode of the command.Once I resolve a code, I wait for 4 bytes designating the length of data that will follow (depending on the command)I create a buffer in my application of size equal to the length I received above.I start receiving the data. 

Note that I have implemented reception of the data in 2 ways (since the 1st way used to work, it was tried as is. Then, I tried the next as well):



a)receive my data using a for loop, reading() one byte at time. until all the expected bytes arrive , or a timeout is reached.

b)receive my data using a while loop where I ask for all the remaining bytes to be read(). Read() returns how many bytes have actually arrived, so I update the remaining Bytes and re-read(). Again if a select() times-out without any data arriving, the loop will exit.


Now, my problem is that while applications seem to be using this port without any problem (f.e. minicom, rx, cat /dev/ttymxc0, echo "something" > /dev/ttymxc0 ) , through the application I get timeouts for any file that is bigger than 3-4kBytes.


Say I am trying to send a file 138kB. I may fail at byte ~40k, ~56k, or even ~12k. This is very weird. And I don't know what to assume is going wrong. Slow processing on the local end seems to not be a problem, as I can read (in (b) above) approx 58 bytes in the beginning and then 1 byte at a time. Could it be the memory buffer? If yes, how can I increase its size? Could another application be interfering with /dev/ttymxc0? 



I am running fsl-image-test with all -dev, -sdk & -dbg options enabled.


Thank you for your help.






 		 	   		  

_______________________________________________
meta-freescale mailing list
meta-freescale at yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-freescale 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20130704/743ccf3f/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ATT00001
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20130704/743ccf3f/attachment.ksh>


More information about the yocto mailing list