0

I'm having some trouble getting my arduino uno to communicate with a simple python script through pyserial.

Lets start with my arduino sketch:

void setup() {
  Serial.begin(9600);
}

byte i = 0;
void loop() {
  Serial.println(i);
  i = i + 1;
}

Really dead simple. It just spews the numbers from 0 to 255 over and over again. It works fine in the arduino serial monitor and gets me the expected result.

The python script comes from:

http://playground.arduino.cc/Interfacing/Python

import serial
ser = serial.Serial('/dev/ttyUSB0', 9600)
while True:
    print ser.readline()

However running this script gets me:

$ python test.py 
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    print ser.readline()
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 460, in read
    raise SerialException('device reports readiness to read but returned no data (device disconnected?)')
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected?)

I am using ubuntu 14.04 and python-serial_2.6-1build1_all.deb

1 Answer 1

1

This may be a kernel bug. See here: https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1501240

The workaround it seems is to use kernel 3.13.0-63-generic.

You can change the kernel for a one-time boot by holding shift while starting up. To make the change persistent, you need to edit /etc/default/grub: https://askubuntu.com/questions/262965/grub-timeout-set-to-0-cant-access-grub-menu-anymore?rq=1

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.