From 404fea7b3bbf45f030a46e2a9224ef82eeac0fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=20=E6=B3=BD=E9=9A=86?= Date: Tue, 21 Jan 2025 10:09:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=87=E4=BB=BD=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E5=8D=87=E7=BA=A7=E5=8C=85=E7=94=9F=E6=88=90=E6=B5=8B?= =?UTF-8?q?=E8=AF=95;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/dev_LaminaAdapter.py | 9 ++++++++- source/dev_station.py | 8 +++++++- source/device/LaminaAdapter.py | 9 ++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/source/dev_LaminaAdapter.py b/source/dev_LaminaAdapter.py index d8e4079..14ce168 100644 --- a/source/dev_LaminaAdapter.py +++ b/source/dev_LaminaAdapter.py @@ -242,7 +242,7 @@ if __name__=='__main__': 'time_out': 3, 'time_gap': 0.1, 'retry': 3, 'retry_sub': 10}, } - dev_lamina = LaminaAdapter(type_dev="SLCP001", **mode_config['Debug']) + dev_lamina = LaminaAdapter(type_dev="SLCP101", **mode_config['Debug']) dev_lamina.frame_read(0x0100, 0x30) @@ -251,6 +251,7 @@ if __name__=='__main__': file_hex = Path(r"D:\WorkingProject\LightStackAdapter\software\lamina_adapter\release\device_V1\lamina_adapter\Debug\lamina_adapter.hex") elif dev_lamina.device == 'SLCP101': file_hex = Path(r"D:\WorkingProject\LightStackAdapter\software\lamina_adapter\release\device_V2.03\lamina_adapter\Debug\lamina_adapter.hex") + file_dat_back = Path(r"D:\WorkingProject\LightStackAdapter\software\tools\hex_history_SLCP101\生产镜像\SLCP101_V2.03\SLCP101_250111_0800_B2.03.dat") elif dev_lamina.device == 'SLCP102': file_hex = Path(r"D:\WorkingProject\LightStackAdapter\software\lamina_adapter\release\device_V3.01\lamina_adapter\Debug\lamina_adapter.hex") elif dev_lamina.device == 'DLSY001': @@ -264,6 +265,12 @@ if __name__=='__main__': print(dev_lamina.device) print(file_hex) + if not hasattr(__builtins__,"__IPYTHON__") and 0: + """ 测试备份程序升级 """ + dev_lamina.frame_update(file_dat_back) + time.sleep(3) + ret = dev_lamina.frame_read(0x0100, 0x20) + if not hasattr(__builtins__,"__IPYTHON__"): version = "SLCP101_241030_2000_V2.03" addr = [0x24, 0x09, 0x12, 0x00, 0x00, 0x00] diff --git a/source/dev_station.py b/source/dev_station.py index 302d046..bceba7d 100644 --- a/source/dev_station.py +++ b/source/dev_station.py @@ -284,8 +284,14 @@ if __name__ == '__main__': "dev27": {'device_id': 'TTE0101HP2411180003', # 文安何庄村新建1 'frame_print': True, 'time_out': 6, 'retry': 1}, + "dev28": {'device_id': 'TTE0101DX2406240043', # 樟山村 + 'frame_print': True, + 'time_out': 6, 'retry': 1}, + "dev29": {'device_id': 'TTE0101DX2409270044', # 行唐西口头 + 'frame_print': True, + 'time_out': 6, 'retry': 1}, } - dev_lamina = LaminaStation(**mode_config["dev27"]) + dev_lamina = LaminaStation(**mode_config["dev29"]) dev_lamina.frame_read(0x0000, 0x20) time.sleep(2) diff --git a/source/device/LaminaAdapter.py b/source/device/LaminaAdapter.py index 9e9ecc0..dbb36c0 100644 --- a/source/device/LaminaAdapter.py +++ b/source/device/LaminaAdapter.py @@ -355,10 +355,17 @@ def GeneratePackage(type_dev: str, path_hex: Path, **kwargs) -> bytearray: print(f"\t header_length={len(main_header)}, bin_length={len(bin_main)}[{hex(len(bin_main))}]") # 组装镜像 - Image = [0xFF] * (len(main_header) + len(encrypt_main)) + if 'upgrade_backup' in kwargs.keys(): + """ 备份程序填充部分字节以便阻止旧版程序进行升级 """ + dummy_data = bytearray([0x00] * 8) + else: + dummy_data = [] + Image = [0xFF] * (len(main_header) + len(dummy_data) + len(encrypt_main)) offset_image = 0 Image[offset_image: offset_image + len(main_header)] = main_header offset_image += len(main_header) + Image[offset_image: offset_image + len(dummy_data)] = dummy_data + offset_image += len(dummy_data) Image[offset_image: offset_image + len(encrypt_main)] = encrypt_main # 额外处理