예제 #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
예제 #4
0
def writeToSerialPort(serialFD, byteArray):
    encodedSLIPBytes = ProtoSLIP.encodeToSLIP(byteArray)
    #convert byte list to a string
    byteString = ''.join(chr(b) for b in encodedSLIPBytes)
    serialFD.write(byteString)
    return
예제 #5
0
def writeToSerialPort(serialFD, byteArray):
    encodedSLIPBytes = ProtoSLIP.encodeToSLIP(byteArray)
    byteString = bytes(encodedSLIPBytes)  #convert byte list to a string
    serialFD.write(byteString)
    return
예제 #6
0
def writeToSerialPort(serialFD, byteArray):  
     encodedSLIPBytes = ProtoSLIP.encodeToSLIP(byteArray)  
     byteString = ''.join(chr(b) for b in encodedSLIPBytes) #convert byte list to a string  
     serialFD.write(byteString)  
     return