Ejemplo n.º 1
0
 def read_message(self):
     while self._running:
         # If we have a message in buffer already, return it
         if len(self._buffer) >= 5 and len(self._buffer) >= self._buffer[1] + 4:
             packet       = self._buffer[:self._buffer[1] + 4]
             self._buffer = self._buffer[self._buffer[1] + 4:]
             return Message.parse(packet)
         # Otherwise, read some data and call the function again
         else:
             data = self._driver.read()
             self._buffer.extend(data)
             _logger.debug("Read data: %s (now have %s in buffer)",
                           format_list(data), format_list(self._buffer))
Ejemplo n.º 2
0
 def read_message(self):
     while self._running:
         # If we have a message in buffer already, return it
         if len(self._buffer) >= 5 and len(
                 self._buffer) >= self._buffer[1] + 4:
             packet = self._buffer[:self._buffer[1] + 4]
             self._buffer = self._buffer[self._buffer[1] + 4:]
             return Message.parse(packet)
         # Otherwise, read some data and call the function again
         else:
             data = self._driver.read()
             self._buffer.extend(data)
             _logger.debug("Read data: %s (now have %s in buffer)",
                           format_list(data), format_list(self._buffer))
Ejemplo n.º 3
0
 def read_message(self):
     # If we have a message in buffer already, return it
     if len(self._buffer) >= 5 and len(self._buffer) >= self._buffer[1] + 4:
         packet       = self._buffer[:self._buffer[1] + 4]
         self._buffer = self._buffer[self._buffer[1] + 4:]
         
         return Message.parse(packet)
     # Otherwise, read some data and call the function again
     else:
         data = self._in.read(4096)
         self._buffer.extend(data)
         if debug_protocol:
             _logger.debug("Read data: %s (now have %s in buffer)",
                           format_list(data), format_list(self._buffer))
         return self.read_message()
Ejemplo n.º 4
0
 def __repr__(self):
     return str.format(
         "<ant.base.Message {0:02x}:{1} (s:{2:02x}, l:{3}, c:{4:02x})>",
         self._id,
         format_list(self._data),
         self._sync,
         self._length,
         self._checksum,
     )
Ejemplo n.º 5
0
 def write_message(self, message):
     data = message.get()
     self._driver.write(data)
     _logger.debug("Write data: %s", format_list(data))
Ejemplo n.º 6
0
 def write_message(self, message):
     data = message.get()
     self._driver.write(data)
     _logger.debug("Write data: %s", format_list(data))
Ejemplo n.º 7
0
Archivo: ant.py Proyecto: La0/GFrun
 def write_message(self, message):
     data = message.get()
     self._out.write(data + array.array('B', [0x00, 0x00]))
     _logger.debug("Write data: %s", format_list(data))
 def write_message(self, message):
     data = message.get()
     self._out.write(data + array.array('B', [0x00, 0x00]))
     _logger.debug("Write data: %s", format_list(data))
Ejemplo n.º 9
0
 def __repr__(self):
     return str.format(
         "<ant.base.Message {0:02x}:{1} (s:{2:02x}, l:{3}, c:{4:02x})>",
         self._id, format_list(self._data), self._sync, self._length,
         self._checksum)