Ejemplo n.º 1
0
 def query(self, data, timeout=None):
     # non blocking
     self.ser.timeout = 0
     self.ser.open()
     self.ser.write(self.prepare_cmd(data))
     # first we should get ACK
     res = self.read_until(self.EOL, self.ACK_TIMOUT)[:-len(self.EOL)]
     # then we should get the data itself
     if res != self.ACK:
         self.ser.close()
         raise DeviceBusyError("Device didn't return ACK")
     res = self.read_until(self.EOL, timeout)[:-len(self.EOL)]
     self.ser.close()
     return res.decode()