]> gitweb.maison.local Git - pyowl.git/commitdiff
Removed non used Windows specific switches
authorLionel <lionel@ra.enneade.fdn.org>
Fri, 24 Oct 2014 13:36:58 +0000 (15:36 +0200)
committerLionel <lionel@ra.enneade.fdn.org>
Fri, 24 Oct 2014 13:36:58 +0000 (15:36 +0200)
cm160Server.py

index 5a25cf089697cb6bacc386c39fcc7405248f2ebd..931c1dae8313c71dfeebf22fad07a8fd0e6e5e9c 100755 (executable)
@@ -344,13 +344,6 @@ class CM160:
   ID_MSG      = "%cIDTCMV001%c" % (MESSAGE_ID_0,1)
   WAIT_MSG    = "%cIDTWAITPCR" % (MESSAGE_ID_0)
 
-  @staticmethod
-  def IsWindows():
-    """Return True if windows platform, False if not"""
-    if platform.system() == "Windows":
-      return True
-    return False
-    
   def __init__(self, uo, serverPort, dataStore, debug):
     self.__uo             = uo
     self.__serverPort     = serverPort
@@ -388,12 +381,8 @@ class CM160:
     s=None
     for i in range(255):
       try:
-        if CM160.IsWindows():
-          portname ="\\.\\COM%d" % (i)
-          s = serial.Serial(portname)
-        else:
-          portname = "/dev/ttyUSB" + `i` # bmcm-p1: force portname on linux
-          s = serial.Serial(portname)
+        portname = "/dev/ttyUSB" + `i` # bmcm-p1: force portname on linux
+        s = serial.Serial(portname)
         s.close()
         available.append( (i, s.portstr))
       except serial.SerialException as e:
@@ -413,18 +402,15 @@ class CM160:
        
     self.__ser = None
     try:
-        if CM160.IsWindows():
-          self.__ser = serial.Serial(self.__serialPortName, 250000, bytesize=8, parity='N', stopbits=1, xonxoff=0, rtscts=0, dsrdtr = 0, timeout=30)   
-        else:
-          #Assume we have the custom cp210x driver loaded that maps the requested baud rate of 0 to a physical port speed of 250000 Bps required 
-          #for the CM160 device.
-          self.__ser = serial.Serial(self.__serialPortName, 0, bytesize=8, parity='N', stopbits=1, xonxoff=False, rtscts=False, dsrdtr = False, timeout=30)    
-          
-          sd = self.__ser.getSettingsDict()        
-          keys = sd.keys()
-          for k in keys:
-            self.__uo.debug("%s=%s" % (k, sd[k]) )
-        self.__uo.info("Opened serial port %s." % (self.__serialPortName) )
+      #Assume we have the custom cp210x driver loaded that maps the requested baud rate of 0 to a physical port speed of 250000 Bps required 
+      #for the CM160 device.
+      self.__ser = serial.Serial(self.__serialPortName, 0, bytesize=8, parity='N', stopbits=1, xonxoff=False, rtscts=False, dsrdtr = False, timeout=30)        
+
+      sd = self.__ser.getSettingsDict()        
+      keys = sd.keys()
+      for k in keys:
+        self.__uo.debug("%s=%s" % (k, sd[k]) )
+      self.__uo.info("Opened serial port %s." % (self.__serialPortName) )
         
     except ValueError:
       #If we fail to open the serial port with a ValueError then it is probably the baud rate that is the problem
@@ -618,13 +604,7 @@ class CM160:
             pass
           
   def connectToSerialPort(self, serialPort):
-    self.__serialPortName = None
-    
-    #We need to do things differently on windows :-(
-    if CM160.IsWindows():
-      self.__serialPortName="\\.\\COM%d" % (serialPort)
-    else:
-      self.__serialPortName = "/dev/ttyUSB%d" % (serialPort)
+    self.__serialPortName = "/dev/ttyUSB%d" % (serialPort)
      
     #If the serial port will open with the CM160 settings
     self.openSerialPort()
@@ -951,14 +931,8 @@ if __name__=='__main__':
         serialPort=int(a)
         
         #Validate serial port
-        lowSerialPort=0
-        if CM160.IsWindows():
-          if serialPort == 0:
-            raise OWLError("Serial port numbering starts at 1, not 0 on Windows platforms.")
-          lowSerialPort=1
-          
-        if serialPort < lowSerialPort or serialPort > 255:
-          raise OWLError("Serial port out of range (%d - 255)." % (lowSerialPort) )
+        if serialPort < 0 or serialPort > 255:
+          raise OWLError("Serial port out of range (0 - 255).")
           
       elif o == "-d":
         debug = True