import struct import logging from datetime import datetime class Command25: def __init__(self): self.command = 0x25 # 25H命令码 def parse_25h(self, data): """解析25H充电信息命令""" try: print("\n开始解析25H充电信息命令...") print(f"接收数据: {data.hex().upper()}") # 基础校验 if len(data) < 14 or data[0:2] != b'JX' or data[2] != self.command: logging.warning("25H命令帧格式不正确") return None # 基础信息解析 pile_id = data[3:11] # 桩号 encrypt_mode = data[11] # 加密方式 data_len = struct.unpack("