summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2002-11-07 02:15:00 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2002-11-07 02:15:00 +0000
commit6ce7ab13836d4cf8ebbcac3739ac41857b787399 (patch)
tree74cdc879341e5c12b930c3b63efc836f3f335eb1
parentb46d253866b80369f89d12b8233b5083c214bb7f (diff)
downloadpyserial-git-6ce7ab13836d4cf8ebbcac3739ac41857b787399.tar.gz
wrong exception on nonexitstent ports with /dev file. bug report by Louis Cordier
-rw-r--r--pyserial/serial/serialposix.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/pyserial/serial/serialposix.py b/pyserial/serial/serialposix.py
index cf77446..f2df972 100644
--- a/pyserial/serial/serialposix.py
+++ b/pyserial/serial/serialposix.py
@@ -12,7 +12,7 @@
import sys, os, fcntl, termios, struct, string, select
import serialutil
-VERSION = string.split("$Revision: 1.11 $")[1] #extract CVS version
+VERSION = string.split("$Revision: 1.12 $")[1] #extract CVS version
PARITY_NONE, PARITY_EVEN, PARITY_ODD = range(3)
STOPBITS_ONE, STOPBITS_TWO = (1, 2)
@@ -169,14 +169,17 @@ class Serial(serialutil.FileLike):
if type(port) == type(''): #strings are taken directly
self.portstr = port
else:
- self.portstr = device(port) #numbers are transformed to a os dependant string
+ self.portstr = device(port) #numbers are transformed to a os dependant string
try:
self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
except Exception, msg:
self.fd = None
raise serialutil.SerialException, "could not open port: %s" % msg
fcntl.fcntl(self.fd, FCNTL.F_SETFL, 0) #set blocking
- self.__tcgetattr() #read current settings
+ try:
+ self.__tcgetattr() #read current settings
+ except termios.error, msg: #if a port is nonexistent but has a /dev file, it'll fail here
+ raise serialutil.SerialException, "could not open port: %s" % msg
#set up raw mode / no echo / binary
self.cflag = self.cflag | (TERMIOS.CLOCAL|TERMIOS.CREAD)
self.lflag = self.lflag & ~(TERMIOS.ICANON|TERMIOS.ECHO|TERMIOS.ECHOE|TERMIOS.ECHOK|TERMIOS.ECHONL|