Esempio n. 1
0
    def test_023_test_serialize_deserialize(self):
        """ Test serializing and deserializing a DeviceBusPacket
        """
        dbp = DeviceBusPacket(sequence=0x00,
                              device_type=0x00,
                              board_id=0x00000000,
                              device_id=0x0000,
                              data=[0x0, 0x0, 0x0])

        packet = dbp.serialize()

        # F everything out so we know deserialization actually did something
        dbp.sequence = 0xFF
        dbp.device_type = 0xFF
        dbp.board_id = 0xFFFFFFFF
        dbp.device_id = 0xFFFF
        dbp.data = [0xFF, 0xFF]

        dbp.deserialize(packet)

        self.assertEqual(dbp.sequence, 0x00)
        self.assertEqual(dbp.device_type, 0x00)
        self.assertEqual(dbp.board_id, 0x00000000)
        self.assertEqual(dbp.device_id, 0x0000)
        self.assertEqual(dbp.data, [0x0, 0x0, 0x0])
Esempio n. 2
0
    def test_024_test_serialize_deserialize(self):
        """ Test serializing and deserializing a DeviceBusPacket
        """
        dbp = DeviceBusPacket(sequence=0xA0,
                              device_type=0xB3,
                              board_id=0xFA00B3E9,
                              device_id=0xF011,
                              data=[0x1B, 0xAA, 0xF0])

        packet = dbp.serialize()

        # 0 everything out so we know deserialization actually did something
        dbp.sequence = 0
        dbp.device_type = 0
        dbp.board_id = 0
        dbp.device_id = 0
        dbp.data = [0]

        dbp.deserialize(packet)

        self.assertEqual(dbp.sequence, 0xA0)
        self.assertEqual(dbp.device_type, 0xB3)
        self.assertEqual(dbp.board_id, 0xFA00B3E9)
        self.assertEqual(dbp.device_id, 0xF011)
        self.assertEqual(dbp.data, [0x1B, 0xAA, 0xF0])
Esempio n. 3
0
    def test_021_test_serialize_deserialize(self):
        """ Test serializing and deserializing a DeviceBusPacket
        """
        dbp = DeviceBusPacket(sequence=0x03,
                              device_type=0x40,
                              board_id=0x12345678,
                              device_id=0xAA05,
                              data=[0x1, 0x2, 0x3])

        packet = dbp.serialize()

        # 0 everything out so we know deserialization actually did something
        dbp.sequence = 0
        dbp.device_type = 0
        dbp.board_id = 0
        dbp.device_id = 0
        dbp.data = [0]

        dbp.deserialize(packet)

        self.assertEqual(dbp.sequence, 0x03)
        self.assertEqual(dbp.device_type, 0x40)
        self.assertEqual(dbp.board_id, 0x12345678)
        self.assertEqual(dbp.device_id, 0xAA05)
        self.assertEqual(dbp.data, [0x1, 0x2, 0x3])