diff options
author | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2013-10-11 14:38:13 +0000 |
---|---|---|
committer | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2013-10-11 14:38:13 +0000 |
commit | 1bb15d7e21be958a32027fdd034f1a602a44816d (patch) | |
tree | 38b1d17474ebec61feebcdcd6afa2145fcdb3b28 | |
parent | c94ebec4ea682bb5c174b0986bc24d726f7213bc (diff) | |
download | pyserial-1bb15d7e21be958a32027fdd034f1a602a44816d.tar.gz |
[Patch pyserial:30] [PATCH 1/1] serial.Serial() should not raise IOError.
also catch errors when getting struct
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@471 f19166aa-fa4f-0410-85c2-fa1106f25c8a
-rw-r--r-- | CHANGES.txt | 1 | ||||
-rw-r--r-- | serial/serialposix.py | 20 |
2 files changed, 11 insertions, 10 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 35d3f65..756fa00 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -462,6 +462,7 @@ Bugfixes (posix): - [Bug pyserial:137] Patch to add non-standard baudrates to Cygwin - [Bug pyserial:141] open: Pass errno from IOError to SerialException - [Bug pyserial:125] Undefined 'base' on list_ports_posix.py, function usb_lsusb +- [Patch pyserial:30] [PATCH 1/1] serial.Serial() should not raise IOError. Bugfixes (win32): diff --git a/serial/serialposix.py b/serial/serialposix.py index e1abce3..131e31b 100644 --- a/serial/serialposix.py +++ b/serial/serialposix.py @@ -45,18 +45,18 @@ if plat[:5] == 'linux': # Linux (confirmed) import array buf = array.array('i', [0] * 64) - # get serial_struct - FCNTL.ioctl(port.fd, TCGETS2, buf) - # set custom speed - buf[2] &= ~TERMIOS.CBAUD - buf[2] |= BOTHER - buf[9] = buf[10] = baudrate - - # set serial_struct try: + # get serial_struct + FCNTL.ioctl(port.fd, TCGETS2, buf) + # set custom speed + buf[2] &= ~TERMIOS.CBAUD + buf[2] |= BOTHER + buf[9] = buf[10] = baudrate + + # set serial_struct res = FCNTL.ioctl(port.fd, TCSETS2, buf) - except IOError: - raise ValueError('Failed to set custom baud rate: %r' % baudrate) + except IOError, e: + raise ValueError('Failed to set custom baud rate (%s): %s' % (baudrate, e)) baudrate_constants = { 0: 0000000, # hang up |