首次提交完整的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

0
structure/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

37
structure/a_frame.py Normal file
View File

@@ -0,0 +1,37 @@
import struct
class AFrame:
def __init__(self, data: bytes):
self.valid = False
self.data_id = 0
self.data_len = 0
self.payload = b""
# A帧最小长度: 4+4+4+4+4+4 + 8 + 2 = 34
if len(data) < 34:
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 != 0x4C3A.to_bytes(2, 'big'):
return
self.valid = True
self.data_id = data_id
self.data_len = dlen
self.payload = payload
except:
pass
def get_doubles(self):
doubles = []
buf = self.payload
while len(buf) >= 8:
d = struct.unpack('>d', buf[:8])[0]
doubles.append(d)
buf = buf[8:]
return doubles

13
structure/b_frame.py Normal file
View File

@@ -0,0 +1,13 @@
# structure/b_frame.py
import struct
B_STAR_TIME_OFFSET = 41 # 根据你协议计算出的星上时偏移(可精调)
B_STAR_TIME_LEN = 6
def build_b_frame(data_id: int, processed_values: list[float]) -> bytes:
# 每个结果占8字节大端double
payload = b"".join(struct.pack('>d', v) for v in processed_values)
data_len = len(payload)
frame = struct.pack('>II', data_id, data_len) + payload
return frame

2
structure/d_frame.py Normal file
View File

@@ -0,0 +1,2 @@
# structure/d_frame.py
D_RAW_DATA_LEN = 54