Kharma
Posts: 2
Joined: Tue May 07, 2013 7:13 am

Serial problem on CPU load

Tue May 07, 2013 7:20 am

Hi, i wonder if any of you could help me as i can't seem to find a solution.

I have a software coded in Python which makes the Raspberry Pi communicate with another device by the serial interface. When i run this software alone, everything seems to be fine and i only have some byte losses here and there, nothing too serious.

On the other hand, when i launch another task on the Raspberry like a pip install or a web server (Pyramid), communications losses are huge to the point where i can't get the communication to work. I go from 90-95% good communication to a mere 10%.

Any advices anyone ? Thanks in advance

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Serial problem on CPU load

Tue May 07, 2013 8:13 am

What baudrate are you using?
Is the device continously sending data or sending it in bursts?
Most uarts have a fifo buffer. Within regular intervals, that buffer needs to be cleared or an overrun will occur causing the system to lose bytes. Usually, an interrupt is generated to inform the system that data is available in the fifo. If such an interrupt isn't handled fast enough (like in case of havy cpu use), an overrun still can occur.
A well designed serial system simply shouldn't lose any data. The misunderstanding that serial communication and data loss walk hand in hand probably comes from the time of modem connections without error correction.

Kharma
Posts: 2
Joined: Tue May 07, 2013 7:13 am

Re: Serial problem on CPU load

Tue May 07, 2013 12:16 pm

Baudrate : 115200 but i also tried with 38400 and it keeps on not running correctly.
The device is sending data in bursts of around 100 bytes but it can vary.
I'm using the module "threading" in python with a thread solely dedicated to the serial reading.
I'm using a very low number of threads (around 5 for this test) and they're mostly I/O related threads with the use of blocking get/put on Queue.

Return to “Troubleshooting”