[GLLUG] Reading USB serial port broken

James Courtier-Dutton james.dutton at gmail.com
Tue Sep 24 20:16:56 UTC 2019

On Fri, 20 Sep 2019 at 08:02, Henrik Morsing via GLLUG
<gllug at mailman.lug.org.uk> wrote:
> Hi,
> I have an Arduino connected via USB to a PC, to read sensors around my house. It calls a Python script as a Munin plugin.
> For quite some time now, and I think this possible broke after an upgrade, the Python script gets no output from ttyACM0.
> Unless I run a 'tail -f' on the device from the command line! Then it works. Otherwise the script just times out getting nothing.
> I'm guessing it's down to a kernel change in how it opens or signals through USB serial devices but what? Googling for a year has found nothing similar to this problem. I'm not really an expert on serial devices and even less on USB serial devices.
> It's getting really frustrating now as the monitoring just never works anymore, so any help appreciated.

Serial programming is notoriously complicated.
I have done it in python before, doing a similar thing that you are doing.
Would you be able to post the python script so we can see how you are
setting up the tty and how you read/write bytes to it?
It is very messing writing python code that catches all possible errors.
For example, I was seeing RF noise coming from all the sensors,
occasionally knocking the USB link off/on.
My python code then had to detect this, close the tty, wait a mo for
it to settle, then open it again.
After that, in the end I dumped Python, and used a mixture of Java, C and C++.
Essentially moving from domogik (Python) to openhab (mainly Java but
with C, C++ for low level device/tty access.)

Kind Regards


More information about the GLLUG mailing list