#!/usr/bin/env python3
|
import struct
|
|
# GPS结构: <dd5fIBB2x
|
# d = double (8 bytes) x 2 = 16
|
# f = float (4 bytes) x 5 = 20
|
# I = uint32 (4 bytes) = 4
|
# B = uint8 (1 byte) x 2 = 2
|
# 2x = padding 2 bytes = 2
|
# Total = 44 bytes
|
|
print(f"GPS结构大小: {struct.calcsize('<dd5fIBB2x')} 字节")
|
|
# 实际GPS载荷
|
gps_payload_hex = "AF92B0EB6EEA4340C5F7EE24DC115D40322452F1A7002435000000350000003CFA3EA4421436A100011B0000"
|
gps_payload = bytes.fromhex(gps_payload_hex)
|
|
print(f"GPS载荷实际大小: {len(gps_payload)} 字节")
|
print()
|
|
# 解析GPS数据
|
data = struct.unpack('<dd5fIBB2x', gps_payload)
|
latitude, longitude, heading, east_vel, north_vel, up_vel, altitude, timestamp, satellites, fix_quality = data
|
|
print(f"纬度: {latitude}°")
|
print(f"经度: {longitude}°")
|
print(f"航向角: {heading}°")
|
print(f"东速度: {east_vel} m/s")
|
print(f"北速度: {north_vel} m/s")
|
print(f"天速度: {up_vel} m/s")
|
print(f"海拔: {altitude} m")
|
print(f"时间戳: {timestamp}")
|
print(f"卫星数: {satellites}")
|
print(f"定位质量: {fix_quality}")
|