简体   繁体   中英

Python struct unpack binary com data

I'm unpacking some byte data I received. I have following the structure record(attached). Unfortunately, my data is encased in C style struct(s) within other structs so it makes unpacking difficult for me. Please see attached screenshot. I'm attempting to unpack p_group but noticed their this a p1224[4] and I'm unsure how to unpack this: (I know struct group_hdr is LH, and I've ignored struct ecg_group for simplicity). It's been tough to find literature on this online. Thanks your help!

hdr_data = struct.unpack_from('<LHhhhh', b,offset=0)
#or
hdr_data = struct.unpack_from('<LHhhhh'*4, b,offset=0)

数据结构

It's the latter.

The [4] indicates that both the group_hdr and the individual short s are multiplied by 4.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM