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


Jeff Osier-Mixon <jefro@...>
 

Hi Thanassis - if there is no reply here, you might try joining and
posting on the meta-freescale mailing list
(https://lists.yoctoproject.org/listinfo/meta-freescale)

On Thu, Jul 4, 2013 at 7:24 AM, Thanassis Silis <djnass_18@...> wrote:


________________________________
From: djnass_18@...
To: meta-freescale@...
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@...
https://lists.yoctoproject.org/listinfo/meta-freescale

_______________________________________________
yocto mailing list
yocto@...
https://lists.yoctoproject.org/listinfo/yocto
--
Jeff Osier-Mixon http://jefro.net/blog
Yocto Project Community Manager @Intel http://yoctoproject.org

Join {yocto@lists.yoctoproject.org to automatically receive all group messages.