import struct import pandas as pd import csv import argparse import sys def parse_metadata(hex_data): """ 解析元数据部分(前112个字符) 元数据结构: type (1字节) : 位置 0-1 direction (1字节) : 位置 2-3 tuigan_stat (1字节) : 位置 4-5 year (1字节) : 位置 6-7 month (1字节) : 位置 8-9 day (1字节) : 位置 10-11 hour (1字节) : 位置 12-13 minute (1字节) : 位置 14-15 second (1字节) : 位置 16-17 NCa (1字节) : 位置 18-19 Ncb (1字节) : 位置 20-21 NCC (1字节) : 位置 22-23 shutter_time (4字节): 位置 24-31 index (8字节) : 位置 32-47 temperature (32字节): 位置 48-111 (8个float,每个4字节) """ # 验证元数据长度 if len(hex_data) < 112: raise ValueError(f"元数据长度不足112个字符,实际长度: {len(hex_data)}") # 解析单字节整数 (u_int8_t) def parse_u8(hex_str): return int(hex_str, 16) # 解析多字节整数 (小端序) def parse_u32(hex_str): return struct.unpack('