def __read(self): result = [] for _ in range(1): message = Message([Frame("1" * 256)]) message.ecu = ECU.ALL message.data = bytearray([randint(0, 255) for _ in range(6)]) result.append(message) return result
def test_message_hex(): message = Message([]) message.data = b'\x00\x01\x02' assert message.hex() == b'000102' assert unhex(message.hex()[0:2]) == 0x00 assert unhex(message.hex()[2:4]) == 0x01 assert unhex(message.hex()[4:6]) == 0x02 assert unhex(message.hex()) == 0x000102
def test_message_hex(): message = Message([]) message.data = b'\x00\x01\x02' assert message.hex() == b'000102' assert int(message.hex()[0:2], 16) == 0x00 assert int(message.hex()[2:4], 16) == 0x01 assert int(message.hex()[4:6], 16) == 0x02 assert int(message.hex(), 16) == 0x000102
def send(self, cmd): # stow this, so we can check that the API made the right request print(cmd) self._last_command = cmd # all commands succeed message = Message([]) message.data = bytearray(b'response data') message.ecu = ECU.ENGINE # picked engine so that simple commands like RPM will work return [message]
def send_and_parse(self, cmd): # stow this, so we can check that the API made the right request print(cmd) self._last_command = cmd # all commands succeed message = Message([]) message.data = bytearray(b'response data') message.ecu = ECU.ENGINE # picked engine so that simple commands like RPM will work return [ message ]
def m(hex_data, frames=None): # most decoders don't look at the underlying frame objects message = Message(frames or []) message.data = bytearray(unhexlify(hex_data)) return [message]
def m(hex_data, frames=[]): # most decoders don't look at the underlying frame objects message = Message(frames) message.data = bytearray(unhexlify(hex_data)) return [message]