Menu

#132 TypeError when unplugging serial USB port while reading

v2.6
closed-works-for-me
None
5
2013-10-17
2012-11-30
No

I'm using pyserial to communicate with an FTDI USB-to-serial converter on Linux (Debian 6, 32). When unplugging the device while reading, pyserial sometimes throws a TypeError:

Python 2.7.3
pyserial: 2.6
Traceback (most recent call last):
File "[hidden]", line XX, in run
byte = self.pyserialHandler.read(1)
File "[...]/site-packages/serial/serialposix.py", line 453, in read
buf = os.read(self.fd, size-len(read))
TypeError: an integer is required

Instead of raising a TypeError, it should fail with a SerialException.

Discussion

  • Moritz Hoffmann

    Moritz Hoffmann - 2012-11-30

    Correct title

     
  • Moritz Hoffmann

    Moritz Hoffmann - 2012-11-30
    • summary: TyepError when unplugging serial USB port while reading --> TypeError when unplugging serial USB port while reading
     
  • Chris Liechti

    Chris Liechti - 2013-10-11
    • status: open --> pending-works-for-me
    • assigned_to: Chris Liechti
    • Group: --> v1.0 (example)
     
  • Chris Liechti

    Chris Liechti - 2013-10-11

    Unclear what is happening here. Are you sure your example isn't using threads and the other one closes the port after it detects an error? This could explain that self.fd becomes None and thus triggers such an exception as you describe.

     
  • Chris Liechti

    Chris Liechti - 2013-10-17
    • Group: v1.0 (example) --> v2.6
     
  • Chris Liechti

    Chris Liechti - 2013-10-17
    • status: pending-works-for-me --> closed-works-for-me
     
  • Chris Liechti

    Chris Liechti - 2013-10-17

    Could not reproduce in my tests with pySerial 2.7. Always getting a SerialException.

     

Log in to post a comment.

MongoDB Logo MongoDB