summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2003-04-30 00:02:09 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2003-04-30 00:02:09 +0000
commitb936fcf09a43aa6e971638b7dda1e28b89ade76c (patch)
treec54e190d0a589c86e77b7133c5d6ee6d614ebb31
parent4d23acd0546559f9e2959cf7bed2697b62f961d2 (diff)
downloadpyserial-git-b936fcf09a43aa6e971638b7dda1e28b89ade76c.tar.gz
dont use DOS device names for ports > 9
-rw-r--r--pyserial/serial/serialwin32.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/pyserial/serial/serialwin32.py b/pyserial/serial/serialwin32.py
index f02be91..a69c4f5 100644
--- a/pyserial/serial/serialwin32.py
+++ b/pyserial/serial/serialwin32.py
@@ -11,7 +11,7 @@ import win32con # constants.
import sys, string
import serialutil
-VERSION = string.split("$Revision: 1.19 $")[1] #extract CVS version
+VERSION = string.split("$Revision: 1.20 $")[1] #extract CVS version
PARITY_NONE, PARITY_EVEN, PARITY_ODD = range(3)
STOPBITS_ONE, STOPBITS_TWO = (1, 2)
@@ -46,8 +46,13 @@ class Serial(serialutil.FileLike):
if type(port) == type(''): #strings are taken directly
self.portstr = port
else:
- self.portstr = 'COM%d' % (port+1) #numbers are transformed to a string
- #self.portstr = '\\\\.\\COM%d' % (port+1) #WIN NT format??
+ #the "//./COMx" format is required for devices > 9
+ #not all versions of windows seem to support this propperly
+ #so that the first few ports are used with the DOS device name
+ if port < 9:
+ self.portstr = 'COM%d' % (port+1) #numbers are transformed to a string
+ else:
+ self.portstr = r'\\.\COM%d' % (port+1)
try:
self.hComPort = win32file.CreateFile(self.portstr,