frame_parse
Parse custom binary frames from hex data by header and length field, with optional checksum. Reports parsing failures and remaining bytes to avoid silent data loss.
Instructions
通用二进制帧解析:按「帧头 + 长度字段」切帧,可选逐帧校验。
单片机自定义协议(上位机抓到的 hex 流)对不上时用。参数都能少填就少填: frame_parse("AA 55 04 01 02 03 04 AA 55 02 05 06") frame_parse("AA 55 04 01 02 03 04", header="AA55", checksum="sum8") frame_parse("01 03 04 00 0A 00 0B 9B F6", checksum="crc16_modbus") header 不给则须给 length_offset(长度字段相对帧首的偏移)。 checksum 可选 "none"/"sum8"/"crc16_modbus"。 ★ 切不出来(找不到帧头 / 长度越界 / 帧被截断)会逐条报出并附剩余字节, 绝不静默丢数据——静默丢帧是这类工具最危险的错。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endian | No | big | |
| header | No | ||
| checksum | No | none | |
| data_hex | Yes | ||
| max_frames | No | ||
| length_size | No | ||
| length_offset | No | ||
| length_includes_header | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |