积累修改;

This commit is contained in:
何 泽隆
2025-01-13 09:10:47 +08:00
parent 5022bf802e
commit 52406c45b9
8 changed files with 3025 additions and 9 deletions

View File

@@ -236,7 +236,7 @@ class LaminaAdapter(DeviceSerial):
self.block['data']['step'] = step
return self._transfer_data()
def frame_update(self, path_file: Path, makefile: bool = False) -> bool:
def frame_update(self, path_file: Path, makefile: bool = False, savefile: bool = False) -> bool:
""" 程序升级
注意: 在使用单板升级测试时, 需要关闭低电压检测功能, 否则无法启动升级流程;
@@ -249,6 +249,8 @@ class LaminaAdapter(DeviceSerial):
raise Exception("工程编译目标文件不存在.")
if makefile and self.make_package is not None:
self.block['data']['file'] = self.make_package(path_file)
if savefile:
path_file.parent.joinpath(path_file.stem + '.dat').write_bytes(self.block['data']['file'])
else:
self.block['data']['file'] = path_file.read_bytes()
@@ -341,6 +343,9 @@ def GeneratePackage(type_dev: str, path_hex: Path, **kwargs) -> bytearray:
if 'output_bin' in kwargs.keys() and kwargs['output_bin']:
(path_hex / (path_hex.stem + '.bin')).write_bytes(bin_main)
if 'output_dat' in kwargs.keys() and kwargs['output_dat']:
(path_hex / (path_hex.stem + '.dat')).write_bytes(bytearray(Image))
return bytearray(Image)
def GenerateImage(type_dev: str, path_boot: Path, path_main: Path, path_back: Path, **kwargs) ->bytearray:

View File

@@ -145,7 +145,7 @@ def make_frame_modbus(block:dict) -> bytearray:
elif block['type'] == "write_str":
frame.append(0x10)
data_len = len(block['data_val'])
item_len = 2 * block['data_define'][data_addr][2]
item_len = 2 * block['data_define'][data_addr][2] if data_addr in block['data_define'].keys() else data_len
data_val = block['data_val']
if data_len > item_len:
raise Exception("Modbus data len oversize.")