예제 #1
0
class ReadingThread(threading.Thread):
    def __init__(self, port):
        threading.Thread.__init__(self)
        self.Serial = Serializer(port)
        if self.Serial.port.isOpen() == False:
            try:
                self.Serial.open()
            except RuntimeError:
                self.PortExceptionHandler()    
    
    def PortReader(self):
        try:
            reading = self.Serial.recv()
        except RuntimeError:

            self.PortExceptionHandler()
        return reading
    
    def PortExceptionHandler(self, tries = 0):
        self.Serial.Close()
        tries =+ 1
        portRetry = [ChecaPuertos.serial_ports()]
        portRetry = portRetry[0]
        self.Serial = Serializer(portRetry)
        print'portexception'
        if self.Serial.port.isOpen() == False:
            try:
                self.Serial.open()
            except RuntimeError:
                if tries > 3:
                    return
                else:
                    self.PortExceptionHandler(tries)
예제 #2
0
 def __init__(self, port):
     threading.Thread.__init__(self)
     self.Serial = Serializer(port)
     if self.Serial.port.isOpen() == False:
         try:
             self.Serial.open()
         except RuntimeError:
             self.PortExceptionHandler()    
예제 #3
0
 def PortExceptionHandler(self, tries = 0):
     self.Serial.Close()
     tries =+ 1
     portRetry = [ChecaPuertos.serial_ports()]
     portRetry = portRetry[0]
     self.Serial = Serializer(portRetry)
     print'portexception'
     if self.Serial.port.isOpen() == False:
         try:
             self.Serial.open()
         except RuntimeError:
             if tries > 3:
                 return
             else:
                 self.PortExceptionHandler(tries)