# -*-coding=utf-8-*- import socket import threading import construct as c import time import binascii import struct import datetime from multiprocessing import Process from memory_storage import MemoryStorage from logging_config import tcp_connector as logger from hard_disk_storage import HardDiskStorage hard_disk_db = HardDiskStorage() # SERVER_ADDRESS = ('172.16.3.0', 50224) SERVER_ADDRESS = ("172.16.3.210", 50224) status_data = c.Struct( magic_number=c.Int32ul, # 固定不便,可能用于区分不同设备 length_mm=c.Int32ul, # 数据包长度 data_head=c.Int32ul, data_head2=c.Int32ul, pack_data=c.Bytes(c.this.length_mm - 12), data_wei=c.Int32ul, ) command_data = c.Struct( magic_number=c.Int32ul, # 固定不便,可能用于区分不同设备 length_mm=c.Int32ul, # 数据包长度 data_head=c.Int32ul, data_head2=c.Int32ul, data_head3=c.Int32ul, pack_data=c.Int32ul, data_wei=c.Int32ul, ) def get_sonar_conf(): sql = "select * from sonar_settings;" result = hard_disk_db.execute_sql(sql, None)[0] return result # 客户端类定义 class Client(Process): # 继承Process类 def __init__(self): super(Client, self).__init__() self.__sock = None self.__connected = False self.__stopped = False self.__ip = SERVER_ADDRESS[0] self.__port = SERVER_ADDRESS[1] self.status_list = {} self.status_len = 248 # 34 # self.status_len = 252 #62 self.open_key = None self.command_head = '0409efbe1400000010000200' self.set_command_dict = {} self.open_command = None self.close_command = None self.range_command_H_s = None self.range_command_V_s = None self.range_command_H_b = None self.range_command_V_b = None self.set_flag = True self.redis_db = None self.send_set_command = 0 self.range_s = 16 self.range_b = 38 self.begin = True self.begin2 = True self.ahrs_status = True def open(self): self.__stopped = False self.start() def run(self): self.__connect() self.__connected = True self.redis_db = MemoryStorage() # t = threading.Thread(target=self.receive_data) # t.start() while True: #sonar_conf = get_sonar_conf() #self.range_b = sonar_conf['range_big'] if len(self.set_command_dict) == 0: begin_data = '3f08efbe0200000028d7' get_status_data = '0409efbe0400000000000400' begin_data_1 = '0409efbe1400000010000100305941378f9a5704236641372659c843' begin_data_2 = '0409efbe1400000010000100305941378f9a57042366413736594036' self.send_command(begin_data) self.send_command(get_status_data) self.send_command(begin_data_1) self.send_command(begin_data_2) self.receive_data() time.sleep(1) # if self.begin == True: # # begin_data_2 = '0409efbe1400000010000100305941378f9a57042366413736594036' # self.send_command(get_status_data) # self.send_command(begin_data_1) # self.send_command(begin_data_1) # self.send_command(begin_data_2) # self.begin = False if self.set_flag == True: for command in self.set_command_dict.values(): self.send_command(command) self.send_command(self.open_command) # print('send_command', self.open_key) time.sleep(0.2) self.send_set_command = self.send_set_command + 1 if self.send_set_command > 2: self.set_flag = False self.send_set_command = 0 if self.redis_db.get_value(['range'])['range'] == 'big' and self.redis_db.get_value(['sonar_status'])['sonar_status'] != 'close': if self.range_command_H_b != None and self.range_command_V_b != None: self.send_command(self.range_command_H_b) self.send_command(self.range_command_V_b) elif self.redis_db.get_value(['range'])['range'] == 'small' and self.redis_db.get_value(['sonar_status'])['sonar_status'] != 'close': if self.range_command_H_s != None and self.range_command_V_s != None: self.send_command(self.range_command_H_s) self.send_command(self.range_command_V_s) if self.redis_db.get_value(['sonar_open'])['sonar_open'] == 'open' and self.redis_db.get_value(['sonar_status'])['sonar_status'] != 'open': if self.open_command != None: self.send_command(self.open_command) print('sonar_open', self.open_command, self.redis_db.get_value(['sonar_status'])['sonar_status']) elif self.redis_db.get_value(['sonar_open'])['sonar_open'] == 'close' and self.redis_db.get_value(['sonar_status'])['sonar_status'] != 'close': if self.close_command != None: self.send_command(self.close_command) print('sonar_close', 2222222222222222) heart_data = '0409efbe1400000010000100305941378f9a5704236641372659c843' self.send_command(heart_data) begin_data_2 = '0409efbe1400000010000100305941378f9a57042366413736594036' self.send_command(begin_data_2) # print('send_command', heart_data) time.sleep(1) def send_command(self, command): if self.__connected: try: send_data = bytes.fromhex(command) self.__sock.send(send_data) except Exception as e: time.sleep(5) self.__reconnect() # logger.info(f'Send command to [{self.name}]:[{self.__ip}]:[{self.__port}] error:{e}') else: self.__reconnect() # 建立socket连接 def __connect(self): if self.__sock: self.__sock.close() self.__sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # 允许重用本地地址和端口 self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) # 在客户端开启心跳维护 self.__sock.settimeout(10) # 设置超时时间3mins try: self.__sock.connect((self.__ip, self.__port)) logger.info(f'Connect to [{self.name}]:[{self.__ip}]:[{self.__port}] success !') self.__connected = True except Exception as e: logger.info(f'Connect to [{self.name}]:[{self.__ip}]:[{self.__port}] failed:{e} !!!') self.__connected = False self.__reconnect() def __reconnect(self): while True: try: if self.__sock: self.__sock.close() self.__sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.__sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) # 在客户端开启心跳维护 self.__sock.settimeout(10) # 设置超时时间,单位:秒 self.__sock.connect((self.__ip, self.__port)) self.set_command_dict = {} self.__connected = True logger.info(f'Reconnect to [{self.name}]:[{self.__ip}]:[{self.__port}] success !') break except Exception as e: logger.info(f'Reconnect to [{self.name}]:[{self.__ip}]:[{self.__port}] failed:{e} !!! Continue reconnect in 5s..') self.__connected = False self.set_command_dict = {} time.sleep(5) def get_str_hex(self, data, offset): data = int(data, 16) data = (data + offset) & 0xff data = struct.pack("=B", data).hex() return data def get_open_command(self, command_head, str_key, mode): a = str_key[0:2] b = str_key[2:4] c = str_key[4:6] d = str_key[6:8] bcd = str_key[2:8] body1 = self.get_str_hex(a, 0x0c) + bcd if mode == 'open': body2 = a + self.get_str_hex(b, 0x33) + self.get_str_hex(c, -0x16) + self.get_str_hex(d, 0x01) elif mode == 'close': body2 = self.get_str_hex(a, 0x01) + self.get_str_hex(b, 0x33) + self.get_str_hex(c, -0x16) + self.get_str_hex(d, 0x01) body3 = self.get_str_hex(a, 0x01) + bcd open_command = command_head + str_key + body1 + body2 + body3 return open_command def get_noise_command(self, command_head, str_key, mode): a = str_key[0:2] bcd = str_key[2:8] body1 = self.get_str_hex(a, 0x04) + bcd body2 = self.get_str_hex(a, 0x09) + bcd if mode == 'close': body3 = self.get_str_hex(a, 0x00) + bcd elif mode == 'low': body3 = self.get_str_hex(a, 0x01) + bcd elif mode == 'med': body3 = self.get_str_hex(a, 0x02) + bcd elif mode == 'hig': body3 = self.get_str_hex(a, 0x03) + bcd body4 = self.get_str_hex(a, 0x04) + bcd command = command_head + body1 + body2 + body3 + body4 return command # 视角和下扫模式可用 def get_tvg_command(self, command_head, str_key, mode): a = str_key[0:2] bcd = str_key[2:8] body1 = self.get_str_hex(a, 0x02) + bcd body2 = self.get_str_hex(a, 0x30) + bcd if mode == 'close': body3 = self.get_str_hex(a, 0x00) + bcd elif mode == 'low': body3 = self.get_str_hex(a, 0x01) + bcd elif mode == 'med': body3 = self.get_str_hex(a, 0x02) + bcd elif mode == 'hig': body3 = self.get_str_hex(a, 0x03) + bcd body4 = self.get_str_hex(a, 0x04) + bcd command = command_head + body1 + body2 + body3 + body4 return command def get_tvg_command_forward(self, command_head, str_key, mode): a = str_key[0:2] bcd = str_key[2:8] body1 = self.get_str_hex(a, 0x04) + bcd body2 = self.get_str_hex(a, 0x30) + bcd if mode == 'close': body3 = self.get_str_hex(a, 0x00) + bcd elif mode == 'low': body3 = self.get_str_hex(a, 0x01) + bcd elif mode == 'med': body3 = self.get_str_hex(a, 0x02) + bcd elif mode == 'hig': body3 = self.get_str_hex(a, 0x03) + bcd body4 = self.get_str_hex(a, 0x04) + bcd command = command_head + body1 + body2 + body3 + body4 return command def ghosting_suppression(self, command_head, str_key, mode): a = str_key[0:2] bcd = str_key[2:8] body1 = self.get_str_hex(a, 0x04) + bcd body2 = self.get_str_hex(a, 0x38) + bcd if mode == 'close': body3 = self.get_str_hex(a, 0x00) + bcd elif mode == 'low': body3 = self.get_str_hex(a, 0x01) + bcd elif mode == 'med': body3 = self.get_str_hex(a, 0x02) + bcd elif mode == 'hig': body3 = self.get_str_hex(a, 0x03) + bcd elif mode == 'auto': body3 = self.get_str_hex(a, 0x04) + bcd body4 = self.get_str_hex(a, 0x04) + bcd command = command_head + body1 + body2 + body3 + body4 return command def get_installation_command(self, command_head, str_key, mode): a = str_key[0:2] b = str_key[2:4] c = str_key[4:6] d = str_key[6:8] bcd = str_key[2:8] body1 = str_key body2 = self.get_str_hex(a, 0x2f) + bcd if mode == 'under': body3 = self.get_str_hex(a, 0x04) + bcd elif mode == 'forward': body3 = self.get_str_hex(a, 0x04) + b + self.get_str_hex(c, 0x01) + d elif mode == 'perspective': body3 = self.get_str_hex(a, 0x10) + b + self.get_str_hex(c, 0x02) + d elif mode == 'auto': body3 = self.get_str_hex(a, 0x10) + b + self.get_str_hex(c, 0x01) + self.get_str_hex(d, 0x80) body4 = self.get_str_hex(a, 0x04) + bcd command = command_head + body1 + body2 + body3 + body4 return command def get_installation_depth_0m_command(self, command_head, str_key): a = str_key[0:2] bcd = str_key[2:8] body1 = self.get_str_hex(a, 0x04) + bcd body2 = self.get_str_hex(a, 0x19) + bcd body3 = str_key body4 = self.get_str_hex(a, 0x04) + bcd command = command_head + body1 + body2 + body3 + body4 return command def get_ahrs_command(self, command_head, str_key, mode): a = str_key[0:2] b = str_key[2:4] c = str_key[4:6] d = str_key[6:8] bcd = str_key[2:8] bcd_2 = self.get_str_hex(b, 0x33) + self.get_str_hex(c, 0xea) + self.get_str_hex(d, 0x01) body1 = str_key body2 = self.get_str_hex(a, 0x1e) + bcd if mode == 'open': body3 = self.get_str_hex(a, 0x01) + bcd_2 elif mode == 'close': body3 = a + bcd_2 body4 = self.get_str_hex(a, 0x01) + bcd command = command_head + body1 + body2 + body3 + body4 return command def get_flip_command(self, command_head, str_key, mode): a = str_key[0:2] b = str_key[2:4] c = str_key[4:6] d = str_key[6:8] bcd = str_key[2:8] bcd_2 = self.get_str_hex(b, 0x33) + self.get_str_hex(c, 0xea) + self.get_str_hex(d, 0x01) body1 = str_key body2 = self.get_str_hex(a, 0x18) + bcd if mode == 'open': body3 = self.get_str_hex(a, 0x01) + bcd_2 elif mode == 'close': body3 = a + bcd_2 body4 = self.get_str_hex(a, 0x01) + bcd command = command_head + body1 + body2 + body3 + body4 return command def get_pitch_command(self, command_head, str_key): a = str_key[0:2] b = str_key[2:4] c = str_key[4:6] d = str_key[6:8] bcd = str_key[2:8] body1 = self.get_str_hex(a, 0x04) + bcd body2 = self.get_str_hex(a, 0x17) + bcd body3 = self.get_str_hex(a, 0x09) + self.get_str_hex(b, 0x98) + self.get_str_hex(c, 0xc4) + self.get_str_hex(d, 0x3e) body4 = self.get_str_hex(a, 0x04) + bcd command = command_head + body1 + body2 + body3 + body4 return command def get_focus_command(self, command_head, str_key, mode): a = str_key[0:2] bcd = str_key[2:8] body1 = str_key body2 = self.get_str_hex(a, 0x33) + bcd if mode == 'salt': body3 = self.get_str_hex(a, 0x01) + bcd elif mode == 'fresh': body3 = self.get_str_hex(a, 0x02) + bcd body4 = self.get_str_hex(a, 0x04) + bcd command = command_head + body1 + body2 + body3 + body4 return command ''' def get_range_command(self, command_head, str_key, mode, range): range_list = [3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30] offset_list = [0x40, 0x80, 0xa0, 0xc0, 0xe0, 0x00, 0x10, 0x20, 0x40, 0x60, 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0] # print(len(range_list),len(offset_list)) if range in range_list: index = range_list.index(range) offset = offset_list[index] a = str_key[0:2] bcd = str_key[2:8] ab = str_key[0:4] c = str_key[4:6] d = str_key[6:8] range_c = self.get_str_hex(c, offset) if range > 7: range_d = self.get_str_hex(d, 0x41) else: range_d = self.get_str_hex(d, 0x40) body1 = self.get_str_hex(a, 0x04) + bcd if mode == 'H': body2 = self.get_str_hex(a, 0x24) + bcd elif mode == 'V': body2 = self.get_str_hex(a, 0x22) + bcd body3 = ab + range_c + range_d body4 = self.get_str_hex(a, 0x04) + bcd command = command_head + body1 + body2 + body3 + body4 return command else: return None ''' def get_range_command(self, command_head, str_key, mode, range): range_list = [3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52] offset_list = [0x40, 0x80, 0xa0, 0xc0, 0xe0, 0x00, 0x10, 0x20, 0x40, 0x60, 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x40, 0x48, 0x50] # print(len(range_list),len(offset_list)) if range in range_list: index = range_list.index(range) offset = offset_list[index] a = str_key[0:2] bcd = str_key[2:8] ab = str_key[0:4] c = str_key[4:6] d = str_key[6:8] range_c = self.get_str_hex(c, offset) if range > 7 and range <= 30: range_d = self.get_str_hex(d, 0x41) elif range <= 7: range_d = self.get_str_hex(d, 0x40) elif range > 30: range_d = self.get_str_hex(d, 0x42) body1 = self.get_str_hex(a, 0x04) + bcd if mode == 'H': body2 = self.get_str_hex(a, 0x24) + bcd elif mode == 'V': body2 = self.get_str_hex(a, 0x22) + bcd body3 = ab + range_c + range_d body4 = self.get_str_hex(a, 0x04) + bcd command = command_head + body1 + body2 + body3 + body4 return command else: return None # 接收服务器发送的数据 def receive_data(self): try: data = self.__sock.recv(self.status_len) except socket.timeout as e: logger.error(f"{self.name}: {e}") time.sleep(5) self.__reconnect() print('recv', e) except Exception as e: logger.error(f"{self.name}: {e}") time.sleep(5) self.__reconnect() if len(data) == self.status_len: self.open_key = data[20:24].hex() print(self.open_key) # if len(self.set_command_dict) < 1: self.open_command = self.get_open_command(self.command_head, self.open_key, 'open') self.close_command = self.get_open_command(self.command_head, self.open_key, 'close') self.range_command_H_s = self.get_range_command(self.command_head, self.open_key, 'H', self.range_s) self.range_command_V_s = self.get_range_command(self.command_head, self.open_key, 'V', self.range_s) self.range_command_H_b = self.get_range_command(self.command_head, self.open_key, 'H', self.range_b) self.range_command_V_b = self.get_range_command(self.command_head, self.open_key, 'V', self.range_b) self.set_command_dict['forward'] = self.get_installation_command(self.command_head, self.open_key, 'forward') self.set_command_dict['noise'] = self.get_noise_command(self.command_head, self.open_key, 'close') self.set_command_dict['tvg_close'] = self.get_tvg_command_forward(self.command_head, self.open_key, 'close') # self.set_command_dict['tvg_hig'] = self.get_tvg_command_forward(self.command_head, self.open_key, 'hig') self.set_command_dict['ghosting_suppression'] = self.ghosting_suppression(self.command_head, self.open_key, 'close') # self.set_command_dict['under'] = self.get_installation_command(self.command_head, self.open_key, 'under') self.set_command_dict['depth_0m'] = self.get_installation_depth_0m_command(self.command_head, self.open_key) self.set_command_dict['focus'] = self.get_focus_command(self.command_head, self.open_key, 'salt') if self.ahrs_status == True: self.set_command_dict['ahrs_open'] = self.get_ahrs_command(self.command_head, self.open_key, 'open') else: self.set_command_dict['ahrs_close'] = self.get_ahrs_command(self.command_head, self.open_key, 'close') self.set_command_dict['flip_close'] = self.get_flip_command(self.command_head, self.open_key, 'close') # self.set_command_dict['flip_open'] = self.get_ahrs_command(self.command_head, self.open_key, 'close' self.set_command_dict['pitch'] = self.get_pitch_command(self.command_head, self.open_key) noise_close = self.get_noise_command(self.command_head, self.open_key, 'close') noise_low = self.get_noise_command(self.command_head, self.open_key, 'low') noise_med = self.get_noise_command(self.command_head, self.open_key, 'med') noise_hig = self.get_noise_command(self.command_head, self.open_key, 'hig') tvg_close = self.get_tvg_command_forward(self.command_head, self.open_key, 'close') tvg_low = self.get_tvg_command_forward(self.command_head, self.open_key, 'low') tvg_med = self.get_tvg_command_forward(self.command_head, self.open_key, 'med') tvg_hig = self.get_tvg_command_forward(self.command_head, self.open_key, 'hig') range_H_3 = self.get_range_command(self.command_head, self.open_key, 'H', 3) range_H_4 = self.get_range_command(self.command_head, self.open_key, 'H', 4) range_H_5 = self.get_range_command(self.command_head, self.open_key, 'H', 5) range_H_6 = self.get_range_command(self.command_head, self.open_key, 'H', 6) range_H_7 = self.get_range_command(self.command_head, self.open_key, 'H', 7) range_H_8 = self.get_range_command(self.command_head, self.open_key, 'H', 8) range_H_9 = self.get_range_command(self.command_head, self.open_key, 'H', 9) range_H_10 = self.get_range_command(self.command_head, self.open_key, 'H', 10) range_H_12 = self.get_range_command(self.command_head, self.open_key, 'H', 12) range_H_14 = self.get_range_command(self.command_head, self.open_key, 'H', 14) range_H_16 = self.get_range_command(self.command_head, self.open_key, 'H', 16) range_H_18 = self.get_range_command(self.command_head, self.open_key, 'H', 18) range_H_20 = self.get_range_command(self.command_head, self.open_key, 'H', 20) range_H_22 = self.get_range_command(self.command_head, self.open_key, 'H', 22) range_H_24 = self.get_range_command(self.command_head, self.open_key, 'H', 24) range_H_26 = self.get_range_command(self.command_head, self.open_key, 'H', 26) range_H_28 = self.get_range_command(self.command_head, self.open_key, 'H', 28) range_H_30 = self.get_range_command(self.command_head, self.open_key, 'H', 30) range_V_3 = self.get_range_command(self.command_head, self.open_key, 'V', 3) range_V_4 = self.get_range_command(self.command_head, self.open_key, 'V', 4) range_V_5 = self.get_range_command(self.command_head, self.open_key, 'V', 5) range_V_6 = self.get_range_command(self.command_head, self.open_key, 'V', 6) range_V_7 = self.get_range_command(self.command_head, self.open_key, 'V', 7) range_V_8 = self.get_range_command(self.command_head, self.open_key, 'V', 8) range_V_9 = self.get_range_command(self.command_head, self.open_key, 'V', 9) range_V_10 = self.get_range_command(self.command_head, self.open_key, 'V', 10) range_V_12 = self.get_range_command(self.command_head, self.open_key, 'V', 12) range_V_14 = self.get_range_command(self.command_head, self.open_key, 'V', 14) range_V_16 = self.get_range_command(self.command_head, self.open_key, 'V', 16) range_V_18 = self.get_range_command(self.command_head, self.open_key, 'V', 18) range_V_20 = self.get_range_command(self.command_head, self.open_key, 'V', 20) range_V_22 = self.get_range_command(self.command_head, self.open_key, 'V', 22) range_V_24 = self.get_range_command(self.command_head, self.open_key, 'V', 24) range_V_26 = self.get_range_command(self.command_head, self.open_key, 'V', 26) range_V_28 = self.get_range_command(self.command_head, self.open_key, 'V', 28) range_V_30 = self.get_range_command(self.command_head, self.open_key, 'V', 30) auto = self.get_installation_command(self.command_head, self.open_key, 'auto') under = self.get_installation_command(self.command_head, self.open_key, 'under') forward = self.get_installation_command(self.command_head, self.open_key, 'forward') perspective = self.get_installation_command(self.command_head, self.open_key, 'perspective') depth_0m = self.get_installation_depth_0m_command(self.command_head, self.open_key) pitch = self.get_pitch_command(self.command_head, self.open_key) ahrs_open = self.get_ahrs_command(self.command_head, self.open_key, 'open') ahrs_close = self.get_ahrs_command(self.command_head, self.open_key, 'close') flip_open = self.get_flip_command(self.command_head, self.open_key, 'open') fiip_close = self.get_flip_command(self.command_head, self.open_key, 'close') focus_salt = self.get_focus_command(self.command_head, self.open_key, 'salt') focus_fresh = self.get_focus_command(self.command_head, self.open_key, 'fresh') ghosting_suppression_close = self.ghosting_suppression(self.command_head, self.open_key, 'close') ghosting_suppression_low = self.ghosting_suppression(self.command_head, self.open_key, 'low') ghosting_suppression_med = self.ghosting_suppression(self.command_head, self.open_key, 'med') ghosting_suppression_hig = self.ghosting_suppression(self.command_head, self.open_key, 'hig') ghosting_suppression_auto = self.ghosting_suppression(self.command_head, self.open_key, 'auto') # self.status_list['1'] # print(data.hex(), end='\n') # if not data: # break command = 1 def hex_to_str1(self, s): # s="68656c6c6f" s = binascii.unhexlify(s) # unhexlify()传入的参数也可以是b'xxxx'(xxxx要符合16进制特征) print(s.decode('utf-8')) # s的类型是bytes类型,用encode()方法转化为str类型 # 启动客户端 if __name__ == '__main__': p = Client() # 实例化进程对象 p.start() # data = '0409efbe140000001000020069e8a9fb89e8a9fb65e8c13d69e8a9fb' # data12 = bytes.fromhex('0409efbe140000001000020069e8a9fb89e8a9fb65e8e93c69e8a9fb') # #'0409efbe 14000000 10000200 69e8a9fb 89e8a9fb 65e8c13d 69e8a9fb' # data10 = bytes.fromhex('0409efbe140000001000020069e8a9fb89e8a9fb65e8c93c69e8a9fb') # # send_data = bytes.fromhex(data) # # data = command_data.parse(send_data) # # print(data) # data12 = command_data.parse(data12) # print(data12) # data10 = command_data.parse(data10) # print(data10) # print(data12.pack_data - data10.pack_data) # # data = '0409efbef00000000800030069e8a9fb9ee8a9fb65e8a9fb65e8a9fb65e8293a64e7a8fa65e8a9fb27a05b3965e8a9fb65e2131065e8a9fb67e8a9fb64e7a8fa65e829ba6575198666f69de965e8a9fb65e8a9fb65e8a9fb65e8a9fb65e8693b668cdead4e2ec03e65e8293a66c9931140f7f23a65884de724f6453966e8a9fb65e8a9fb80e8a9fb80e8a9fb6675198665f79de965e8a9fb65e8a9fb65e8493b6527c89d65e8c13d65884de769e8a9fb65e8a9fb65e8a9fb65e8a9fb65e8a9fb65e8a9fb66884de7658cdead65e8a9fb75e8aafb65e8a9fb6502f91ce2e8a9fb67e8a9fb65e8a9fb65e8693b66884de765884de769e8a9fb' # # send_data = bytes.fromhex(data) # # data = status_data.parse(send_data) # # print(data)