我有一个十六进制数据块,其中包括传感器的设置,我将包括十六进制的开始代码段(LSB在前):
F501517C 8150D4DE 04010200 7001010105F32A04 F4467000 00000AFF 0502D402
这直接来自文档,将十六进制解码为dec:
Offset Length (bytes) Field description
0x00 6 Full identifier
0x06 40 Settings
Offset Field description
0x00 Product Type
0x01 Device Type
0x02 Software Major Version
0x03 Software Minor Version
0x04 Hardware Major Version
0x05 Hardware Minor Version
Offset Length(bit) Offset(bit) Default value Min Max Field Description
0x00 8 0 0 0 255 Country number
0x01 8 0 0 0 255 District number
0x02 16 0 0 0 9999 Sensor number
...
0x27
这是我唯一需要解码的信息。偏移列必须是理解这一点的技巧。
Value in dump - separated in bytes - bytes in memory
F501517C - F5 01 51 7C - 7C 51 01 F5
8150D4DE - 81 50 D4 DE - DE D4 50 81
04010200 - 04 01 02 00 - 00 02 01 04
现在让我们将它们分配给字段。下一个列表将两个记录串联在一起。
Byte Offset Field description
7C 0x00 Product Type
51 0x01 Device Type
01 0x02 Software Major Version
F5 0x03 Software Minor Version
DE 0x04 Hardware Major Version
D4 0x05 Hardware Minor Version
Byte Offset Length(bit) Offset(bit) Default value Min Max Field Description
50 0x00 8 0 0 0 255 Country number
81 0x01 8 0 0 0 255 District number
00,02 0x02 16 0 0 0 9999 Sensor number
结果是否有意义,是您的决定:
产品类型= 0x7C
设备类型= 0x51 = 81十进制(也可以是ASCII'Q')软件专业版次要版本= 0x01.0xF5 = 1.245十进制