diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000..06d7405 Binary files /dev/null and b/utils/__init__.py differ diff --git a/utils/packet.py b/utils/packet.py new file mode 100644 index 0000000..358c8ba --- /dev/null +++ b/utils/packet.py @@ -0,0 +1,22 @@ +import struct + +HEAD_STANDARD = 0x05 +HEAD_FOTA = 0x15 +CMD_GET_BUILD = 0x1E08 +CMD_READ_FLASH = 0x0403 +CMD_GET_BD_ADDR = 0x0C05 + +def build_race_packet(cmd: int, payload: bytes = b'', head: int = HEAD_STANDARD) -> bytes: + pkt_type = 0x00 + length = 2 + len(payload) + header = struct.pack(' dict: + if len(data) < 6: + return {"error": "Packet too short"} + head, pkt_type, length = struct.unpack_from('