diff --git a/source/dev_LaminaAdapter.py b/source/dev_LaminaAdapter.py index f41fdc4..db39f4f 100644 --- a/source/dev_LaminaAdapter.py +++ b/source/dev_LaminaAdapter.py @@ -3,6 +3,7 @@ from pathlib import Path from serial import Serial from tools.ByteConv import trans_list_to_str from func_frame import make_frame_dlt645, check_frame_dlt645 +from func_upgrade import GeneratePackage_SLCP101_p460 modbus_map = { # 1 - Hex @@ -349,12 +350,26 @@ def test_communication(time_out=2): print(f"Success Rate: {log_success / (log_success + log_failed) * 100}%") dev_lamina.flag_print = saveconfig_print +def make_Pakeage(fp: Path): + """ 生成升级包 """ + + hex_update = fp + file_package = fp.parent / f'{hex_update.stem}.dat' + file_update_bin = fp.parent / f'{hex_update.stem}.bin' + + data_package, data_update_bin = GeneratePackage_SLCP101_p460(hex_update) + + file_package.write_bytes(data_package) + file_update_bin.write_bytes(data_update_bin) + + return file_package + if __name__=='__main__': mode_config = { "Log": {'com_name': None, # 'addr_645': [0x01, 0x00, 0x00, 0x00, 0x00, 0x40], }, - "Debug": {'com_name': 'COM11', 'baudrate': 115200, 'parity': 'N', 'bytesize': 8, 'stopbits': 1, + "Debug": {'com_name': 'COM8', 'baudrate': 115200, 'parity': 'N', 'bytesize': 8, 'stopbits': 1, # 'addr_645': [0x01, 0x02, 0x03, 0x04, 0x05, 0x06], 'frame_print': True, 'time_out': 0.1, 'retry': 1, 'retry_sub': 10}, @@ -364,7 +379,6 @@ if __name__=='__main__': 'time_out': 0.5, 'retry': 3, 'retry_sub': 10}, } - dev_lamina = LaminaAdapter(**mode_config['Debug']) dev_lamina.frame_read(0x0100, 0x20) @@ -458,10 +472,14 @@ if __name__=='__main__': dev_lamina.frame_read(0x0170, 0x30) if not hasattr(__builtins__,"__IPYTHON__"): - path_bin = Path(r"D:\WorkSpace\UserTool\SelfTool\FrameParser\test\p460_o1\result\lamina_optimizer_t1.dat") + # file_package = Path(r"D:\WorkSpace\UserTool\SelfTool\FrameParser\test\p460_o1\result\lamina_optimizer_t1.dat") # path_bin = Path(r"D:\WorkingProject\LightStackAdapter\software\lamina_adapter\tools\upgrade\SLCP001_240520_0000_T1.11.bin") - # 生产镜像版本 - # path_bin = Path(r"D:\WorkingProject\LightStackAdapter\software\lamina_adapter\tools\upgrade\SLCP001_240525_1800_V1.12.bin") + # 工程-即时转换 + file_hex = Path(r"D:\WorkingProject\LightStackAdapter\software\lamina_adapter\lamina_adapter\Debug\lamina_adapter.hex") + if not file_hex.exists(): + raise Exception("工程编译目标文件不存在.") + file_package = make_Pakeage(file_hex) + # 江苏发货产品灌装版本 # path_bin = Path(r"D:\WorkingProject\LightStackAdapter\software\lamina_adapter\tools\upgrade\SLCP001_240603_2100_V1.18.bin") @@ -476,7 +494,7 @@ if __name__=='__main__': ret = dev_lamina.frame_read(0x0100, 0x20) time.sleep(1) - dev_lamina.frame_update(path_bin) + dev_lamina.frame_update(file_package) time.sleep(6) diff --git a/source/func_upgrade.py b/source/func_upgrade.py index c0b10b5..4561663 100644 --- a/source/func_upgrade.py +++ b/source/func_upgrade.py @@ -319,7 +319,7 @@ def GenerateImage_SLCP001_p4a0(path_boot: Path, path_main: Path, path_back: Path return bytearray(Image), main_header, back_header -def GenerateImage_SLCP001_p460(path_boot: Path, path_main: Path, path_back: Path): +def GenerateImage_SLCP101_p460(path_boot: Path, path_main: Path, path_back: Path): """ 叠光适配器-460平台版本 镜像生成 """ config = { 'prod_type': [0x45, 0x00], # 产品类型 @@ -374,12 +374,12 @@ def GenerateImage_SLCP001_p460(path_boot: Path, path_main: Path, path_back: Path return bytearray(Image), main_header, back_header -def GeneratePackage_SLCP001_p460(path_hex: Path): +def GeneratePackage_SLCP101_p460(path_hex: Path): """ 叠光适配器-460平台版本 生成升级包 """ config = { 'prod_type': [0x45, 0x00], # 产品类型 'method_compress': False, # 文件压缩 - 'prog_id': list(b"SLCP001"), # 程序识别号 + 'prog_id': list(b"SLCP101"), # 程序识别号 'prog_type': 'app', # 程序类型 'area_code': [0x00, 0x00], # 地区 } @@ -411,7 +411,7 @@ def GeneratePackage_SLCP001_p460(path_hex: Path): def GenerateImage_DLSY001_p460(path_boot: Path, path_main: Path, path_back: Path): - """ 叠光适配器-460平台版本 镜像生成 """ + """ 叠光优化器-460平台版本 镜像生成 """ config = { 'prod_type': [0x45, 0x00], # 产品类型 'method_compress': False, # 文件压缩 @@ -466,7 +466,7 @@ def GenerateImage_DLSY001_p460(path_boot: Path, path_main: Path, path_back: Path def GeneratePackage_DLSY001_p460(path_hex: Path): - """ 叠光适配器-460平台版本 生成升级包 """ + """ 叠光优化器-460平台版本 生成升级包 """ config = { 'prod_type': [0x45, 0x00], # 产品类型 'method_compress': False, # 文件压缩 @@ -616,13 +616,13 @@ def Process1(): hex_update = root / r"lamina_adapter_t1.hex" file_image = result / f'{hex_main.stem[:-6]}_ROM.bin' - file_main_header = result / 'SLCP001_header_main.bin' - file_back_header = result / 'SLCP001_header_back.bin' + file_main_header = result / 'SLCP101_header_main.bin' + file_back_header = result / 'SLCP101_header_back.bin' file_package = result / f'{hex_update.stem}.dat' file_bin = result / f'{hex_update.stem}.bin' - data_bins = GenerateImage_SLCP001_p460(hex_boot, hex_main, hex_back) - data_package, data_bins = GeneratePackage_SLCP001_p460(hex_update) + data_bins = GenerateImage_SLCP101_p460(hex_boot, hex_main, hex_back) + data_package, data_bins = GeneratePackage_SLCP101_p460(hex_update) file_image.write_bytes(data_bins[0].copy()) file_main_header.write_bytes(data_bins[1].copy())