I have an Arduino Uno (R3) monitoring a magnetometer connected via USB to a PI (B) running latest Raspian. My Pi Python program scans the USB every second reading an integer value via ser = serial.Serial('/dev/ttyACM0', 57600).

This works fine when run from an active terminal. However I want to run the Python program starting at boot. Now the Python program fails to read the USB state.

I have tried starting the program via both rc.local and crontab. In either case the Python script is happy, reading/writing its data files, but fails when it tries to access USB. I have inserted a wait of up to 2 min assuming that USB may take time to initialize.

I wonder whether the USB is disabled until active login? Am I simply being dim here? :-)


Sorted it. The problem was that I was not flushing the buffer first

ser = serial.Serial('/dev/ttyACM0', 57600)
  • Perhaps also consider setting timeout when you open the device – scruss May 31 '17 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.