docs(issue#3): 联调闭环——客户192.168.5.210登录+提交+回执全链打通(-1终结;首报0=余额不足);分析器边界扫描容错
This commit is contained in:
@@ -140,13 +140,14 @@ def reassemble(events):
|
||||
def split_pdus(buf):
|
||||
out, off = [], 0
|
||||
while off + 12 <= len(buf):
|
||||
total = struct.unpack(">I", buf[off:off + 4])[0]
|
||||
if total < 13 or total > 65535:
|
||||
break
|
||||
total, cmd = struct.unpack(">II", buf[off:off + 8])
|
||||
# 帧头合法性:长度窗口 + 已知命令字;不合法则滑动 1B 扫描(重组边界漂移容错)
|
||||
if total < 13 or total > 65535 or cmd not in CMDS:
|
||||
off += 1
|
||||
continue
|
||||
if off + total > len(buf):
|
||||
break # 尾部截断(环形切片)
|
||||
out.append((struct.unpack(">I", buf[off + 4:off + 8])[0],
|
||||
struct.unpack(">I", buf[off + 8:off + 12])[0],
|
||||
out.append((cmd, struct.unpack(">I", buf[off + 8:off + 12])[0],
|
||||
buf[off + 12:off + total]))
|
||||
off += total
|
||||
return out, buf[off:]
|
||||
|
||||
Reference in New Issue
Block a user