首次提交完整的python工程代码

This commit is contained in:
2026-06-15 20:38:42 +08:00
commit bca485d748
159 changed files with 248076 additions and 0 deletions

35
protocol/a_frame.py Normal file
View File

@@ -0,0 +1,35 @@
import struct
class AFrame:
def __init__(self, data: bytes):
self.valid = False
self.data_id = 0
self.payload = b""
self.values = []
if len(data) < 24 + 8 + 2:
return
try:
magic, dlen, dir_, data_id, ptype, sat = struct.unpack('>IIIIII', data[:24])
payload = data[24:-2]
tail = data[-2:]
if magic != 0xEB90EB90 or tail != b'\x4C\x3A':
return
self.valid = True
self.data_id = data_id
self.payload = payload
# 按8字节切分double
vs = []
buf = payload
while len(buf) >= 8:
v = struct.unpack('>d', buf[:8])[0]
vs.append(v)
buf = buf[8:]
self.values = vs
except:
pass