0
我有以下簡單的協議框架。爲了測試,我假設一個固定的CRC字段,但現在我需要添加從幀中先前字節計算出的實際CRC。怎麼做?也許通過嵌套結構?使用Construct添加CRC字段python庫
MyFrame = Struct("MyFrame",
ULInt8("type"),
ULInt8("IDMsg"),
ULInt8("totalPackets"),
ULInt8("numPacket"),
ULInt8("day"),
ULInt8("month"),
ULInt8("year"),
ULInt8("hour"),
ULInt8("minute"),
ULInt8("second"),
ULInt16("length"),
Bytes("payload", lambda ctx: (ctx.length - 14)),
ULInt16("crc")
)