Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyserial: could not configure port: (5, 'Input/output error)

I've been trying to get the following two lines of Python code to run for the past two days, without much success:

import serial
ser = serial.Serial(0)

Each time I run it, I get the following error:

Traceback (most recent call last):
  File "./test.py", line 4, in <module>
    ser = serial.Serial(0)
  File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 260, in __init__
    self.open()
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 280, in open
    self._reconfigurePort()
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 308, in _reconfigurePort
    raise SerialException("Could not configure port: %s" % msg)
serial.serialutil.SerialException: Could not configure port: (5, 'Input/output error')

I'm running Ubuntu 11.10 64-bit, with Pyserial 2.5 (python-serial 2.5-2.1) and Python 2.7 (python 2.7.2-7ubuntu2) and my user is a member of the dialout group.

I run Ubuntu 11.10 64-bit at work too, with the same versions of Python and Pyserial, and the problem doesn't seem to occur there. Any suggestions are welcome - I'm pretty flummoxed...

Thanks, Donagh

like image 683
Donagh Avatar asked Apr 16 '12 20:04

Donagh


1 Answers

This exception is thrown if the port is not available. On Linux, you can simply specify the exact name of the port to use, like

ser = serial.Serial('/dev/ttyACM0')
like image 139
phihag Avatar answered Sep 22 '22 22:09

phihag