On Fri, May 18, 2012 at 2:53 PM, Ron Eggler <rondotegg...@tscheemail.com> wrote: > Hoi, > > I'm trying to connect to a serial port and always get the error > "serial.serialutil.SerialException: Port is already open." whcih is untrue. > I have no serial port open yet, my code looks like this: > #!/usr/bin/python > import time > import serial > > # configure the serial connections (the parameters differs on the device > # you are connecting to) > ser = serial.Serial( > port='/dev/ttyUSB0', > baudrate=19200, > parity=serial.PARITY_ODD, > stopbits=serial.STOPBITS_TWO, > bytesize=serial.SEVENBITS > ) > > ser.open() > > Why do I get this error?
Read the fine documentation. http://pyserial.sourceforge.net/pyserial_api.html#serial.Serial.__init__ (emphasis added): "The port is **immediately opened** on object creation, when a port is given. It is not opened when port is None and a successive call to open() will be needed." So the port is indeed already open since you specified port='/dev/ttyUSB0'; thus, your .open() call is redundant. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list