Ejemplo n.º 1
0
 def test_invalid_initial_data(self):
     """Test invalid data received."""
     hex_data = "9903040502520380"
     msg_bytes = bytearray(unhexlify(hex_data))
     msg, remaining_bytes = create(msg_bytes)
     assert remaining_bytes == b""
     assert msg.message_id == 0x52
Ejemplo n.º 2
0
 def test_invalid_msg_def_message(self):
     """Test partial message received."""
     hex_data = "02990304050253"
     msg_bytes = bytearray(unhexlify(hex_data))
     expected_bytes = bytearray(unhexlify("0253"))
     _, remaining_bytes = create(msg_bytes)
     assert remaining_bytes == expected_bytes
Ejemplo n.º 3
0
 def test_extra_data(self):
     """Test extra data received."""
     hex_data = "02520380025203"
     msg_bytes = bytearray(unhexlify(hex_data))
     expected_bytes = bytearray(unhexlify("025203"))
     msg, remaining_bytes = create(msg_bytes)
     assert msg.message_id == 0x52
     assert remaining_bytes == expected_bytes
Ejemplo n.º 4
0
    def setUp(self):
        """Setup the tests."""
        self.hex_data = "0250010203040506272829"
        # address: 01.02.03
        # target: 04.05.06
        # flags: 27 (direct_ack)
        # cmd1: 28 (set_address_msb)
        # cmd2: 29
        self.bytes_data = bytearray(unhexlify(self.hex_data))

        (self.msg, _) = create(self.bytes_data)
        for (self.topic, self.kwargs) in convert_to_topic(self.msg):
            pass
Ejemplo n.º 5
0
 def test_partial_standard_message(self):
     """Test partial message received."""
     hex_data = "02620304050999"
     msg_bytes = bytearray(unhexlify(hex_data))
     _, remaining_bytes = create(msg_bytes)
     assert remaining_bytes == msg_bytes
Ejemplo n.º 6
0
 def test_one_byte(self):
     """Test a single byte message."""
     hex_data = "02"
     msg_bytes = bytearray(unhexlify(hex_data))
     _, remaining_bytes = create(msg_bytes)
     assert remaining_bytes == msg_bytes
Ejemplo n.º 7
0
def hex_to_inbound_message(hex_data):
    """Create an Inbound message from a hex string."""
    msg_bytes = bytearray(unhexlify(hex_data))
    (msg, _) = create(msg_bytes)
    return msg, msg_bytes