예제 #1
0
def readFromSerialPort(serialFD):
    i = 1
    byteArray = None
    byteArray = ProtoSLIP.decodeFromSLIP(serialFD)
    if byteArray is None:
        return -1
    else:
        return byteArray
예제 #2
0
def readFromSerialPort(serialFD):  
     i = 1  
     byteArray = None  
     byteArray = ProtoSLIP.decodeFromSLIP(serialFD)  
     if byteArray is None:  
          print "readFromSerialPort(serialFD): Error"  
          return -1  
     else:  
          return byteArray  
 def _loop(self):
     while (True):
         bytes = ProtoSLIP.decodeFromSLIP(self.serial_port)
         values = []
         if len(bytes) >= 2:
             for i in range(0, len(bytes), 2):
                 values.append(bytes[i] << 8 | bytes[i + 1])
             self.callback(
                 values, lambda x: SerialComm.writeToSerialPort(
                     self.serial_port, x))
         time.sleep(self.sleep_time)
     self.serial_port.flush()
     SerialComm.disconnectFromSerialPort(self.serial_port)
     return