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 /serial | |
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
Diffstat (limited to 'serial')
-rw-r--r-- | serial/serialposix.py | 20 |
1 files changed, 10 insertions, 10 deletions
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 |