Example #1
0
    def test_checksum(self):
        packet = bytes.fromhex(
            "7565 0C20 0D08 0103 1200 0A04 000A 0500 0A13 0A01 0511 000A 1000 0A01 000A 0200 0A03 000A D43D"
        )
        verify_checksum(packet)

        ping = bytes.fromhex('7565 0102 0201 E0C6')
        verify_checksum(ping)
Example #2
0
    def test_invalid_checksum(self):
        raw_data = bytes.fromhex(
            '75658252100d3d3302803c68b2e03cee54000001100e3bb32f1f3b0ed8403a637b3e00010e14000000000'
            '00000000001000214033c7a802ebf4e2607bf17b2a78ae04161ef4e0001100ebd08efc83ebe409a3cb8df380001'
        )
        self.assertFalse(verify_checksum(raw_data))

        packet, new_buf = get_packet(raw_data + bytes.fromhex('1234'))
        self.assertIsNone(packet)
        self.assertEqual(new_buf, bytes.fromhex('1234'))
Example #3
0
 def test_parse_gps(self):
     verify_checksum(SAMPLE_GPS_DATA)
     __, __, __, __, gps = parse_packet(SAMPLE_GPS_DATA)
     self.assertEqual(gps, ((49.9115015, 14.199715099999999), 9,
                            datetime.datetime(2019, 6, 16, 9, 13, 17)))