对于一些协议帧进行解码处理学习,这个也是网上搜到的,供一起学习参考![](https://aar.chengxu.online/upload/files/20240714/1720956822.gif)
结构体编码组帧学习请移步这里指导:结构体学习:协议的编码
import console;
import string;
import fsys.stream
var data=string.unhex("FF24010000C0A800ABD4AD2075CB75331C01005A69674265654855422D34383500000040","")
/*
var opcommon=class{
byte Version[5];
byte IP[4];
byte Mac[6];
prop=function(a){
return ..string.hex(this[a],"")
}
}
var op=opcommon();
var f=fsys.stream(data)
f.read(op)
//console.varDump(data,op.prop("Mac"))
console.log(op.prop("Mac"))
var opcommon={byte Header[5];byte IP[4];byte Mac[6];byte Ver[4];byte Mode[16];byte CheckCode[1]}//Version=0x0111,Code=0x8005,Status=0x00000000
var f=fsys.stream(data)
f.read(opcommon)
console.varDump(data,opcommon)
console.log(string.hex(opcommon.Header," "))
console.log(string.hex(opcommon.IP," "))
console.log(string.hex(opcommon.Mac," "))
console.log(string.hex(opcommon.Ver," "))
console.log(string.hex(opcommon.Mode," "))
console.log(string.hex(opcommon.CheckCode," "))
console.pause(true);