lenz-flashtool 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/.gitignore +3 -1
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/PKG-INFO +2 -2
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/biss/cli.py +1 -1
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/biss_io.py +72 -30
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/data_streaming.py +4 -4
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/operations.py +1 -7
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/pyproject.toml +1 -1
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/LICENSE +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/README.md +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/__init__.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/biss/__init__.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/biss/commands.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/biss/crc.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/biss/encoder_state.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/biss/registers.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/encproc/__init__.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/encproc/processing.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/__init__.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/bootloader.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/core.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/encoder_control.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/errors.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/ft_bl_connection.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/hex_generator.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/hex_utils.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/logging.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/mock_flashtool.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/serial_io.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/timing.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/flashtool/uart.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/testing/__init__.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/testing/mock_flashtool.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/utils/__init__.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/utils/plot.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/utils/progress.py +0 -0
- {lenz_flashtool-0.2.0 → lenz_flashtool-0.2.1}/lenz_flashtool/utils/termcolors.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: lenz-flashtool
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: FlashTool library for BiSS C Firmware Update and Calibration by LENZ Encoders
|
|
5
5
|
Project-URL: Homepage, https://github.com/lenzencoders/lenz-flashtool-lib
|
|
6
6
|
Project-URL: Source, https://github.com/lenzencoders/lenz-flashtool-lib
|
|
@@ -844,7 +844,7 @@ class BiSSIOMixin:
|
|
|
844
844
|
degree_sign = "\N{DEGREE SIGN}"
|
|
845
845
|
try:
|
|
846
846
|
ans, _ = self.read_data_enc1_AB_enc2_SPI(0.01, False)
|
|
847
|
-
if
|
|
847
|
+
if len(ans) < 1:
|
|
848
848
|
logger.error("No valid data received from encoder")
|
|
849
849
|
return
|
|
850
850
|
|
|
@@ -862,7 +862,6 @@ class BiSSIOMixin:
|
|
|
862
862
|
f"{minutes:02d}' "
|
|
863
863
|
f"{seconds:05.2f}\"")
|
|
864
864
|
|
|
865
|
-
sys.stdout.write("\r" + output + " " * 10)
|
|
866
865
|
logger.debug(output)
|
|
867
866
|
|
|
868
867
|
except ValueError as e:
|
|
@@ -1015,50 +1014,93 @@ class BiSSIOMixin:
|
|
|
1015
1014
|
INFO: Done uploading!
|
|
1016
1015
|
"""
|
|
1017
1016
|
max_retries = 3
|
|
1017
|
+
retry_delay = 0.2
|
|
1018
1018
|
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1019
|
+
first_idx = start_page - 1
|
|
1020
|
+
last_idx = min(end_page - 1, len(pages) - 1)
|
|
1021
|
+
|
|
1022
|
+
ordered_indices = [i for i in range(first_idx, last_idx + 1) if i != 0]
|
|
1023
|
+
if first_idx <= 0 <= last_idx:
|
|
1024
|
+
ordered_indices.append(0)
|
|
1025
|
+
|
|
1026
|
+
for idx in ordered_indices:
|
|
1027
|
+
page_data = pages[idx]
|
|
1028
|
+
crc = crc_values[idx]
|
|
1029
|
+
page_num = page_numbers[idx]
|
|
1030
|
+
page_idx = idx + 1
|
|
1022
1031
|
|
|
1023
1032
|
retry_count = 0
|
|
1024
1033
|
success = False
|
|
1025
1034
|
|
|
1035
|
+
|
|
1026
1036
|
while retry_count < max_retries and not success:
|
|
1027
|
-
|
|
1028
|
-
|
|
1037
|
+
try:
|
|
1038
|
+
# Every page writes its own CRC and page number
|
|
1029
1039
|
self.biss_set_bank(BiSSBank.BISS_BANK_SERV)
|
|
1030
1040
|
self.biss_write_word(BiSSBank.CRC32_REG_INDEX, crc)
|
|
1031
1041
|
self.biss_write_word(BiSSBank.PAGENUM_REG_INDEX, page_num)
|
|
1032
1042
|
time.sleep(0.01)
|
|
1033
1043
|
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
time.sleep(0.3)
|
|
1047
|
-
if difmode:
|
|
1048
|
-
self.biss_write_command('savediftable')
|
|
1049
|
-
else:
|
|
1050
|
-
self.biss_write_command('load2k')
|
|
1044
|
+
# Send each bank in the page
|
|
1045
|
+
for bank_idx, bank_data in enumerate(page_data):
|
|
1046
|
+
bank_num = bank_idx + BiSSBank.BISS_USERBANK_START
|
|
1047
|
+
if bank_num == 5:
|
|
1048
|
+
self.biss_set_bank(bank_num)
|
|
1049
|
+
time.sleep(0.05)
|
|
1050
|
+
|
|
1051
|
+
if pbar:
|
|
1052
|
+
percent_complete(bank_idx, BiSSBank.BANKS_PER_PAGE - 1, title=f"Sending Page {page_idx}",)
|
|
1053
|
+
|
|
1054
|
+
hex_line = generate_hex_line(0, UartCmd.HEX_WRITE_CMD, bank_data)
|
|
1055
|
+
self.hex_line_send(hex_line)
|
|
1051
1056
|
|
|
1052
|
-
|
|
1057
|
+
time.sleep(0.3)
|
|
1058
|
+
|
|
1059
|
+
if difmode:
|
|
1060
|
+
self.biss_write_command('savediftable')
|
|
1061
|
+
else:
|
|
1062
|
+
self.biss_write_command('load2k')
|
|
1063
|
+
|
|
1064
|
+
time.sleep(1.25)
|
|
1065
|
+
|
|
1066
|
+
crc_error = bool(self.biss_read_flags_flashCRC()[0])
|
|
1067
|
+
|
|
1068
|
+
except FlashToolError as exc:
|
|
1069
|
+
retry_count += 1
|
|
1053
1070
|
|
|
1054
|
-
|
|
1071
|
+
logger.error("Page %s transmission error (attempt %s/%s): %s", page_idx, retry_count, max_retries, exc,)
|
|
1072
|
+
|
|
1073
|
+
if retry_count >= max_retries:
|
|
1074
|
+
logger.critical("Failed to send page %s after %s attempts", page_idx, max_retries,)
|
|
1075
|
+
raise FlashToolError(
|
|
1076
|
+
f"Failed to send page {page_idx} "
|
|
1077
|
+
f"after {max_retries} attempts: {exc}"
|
|
1078
|
+
) from exc
|
|
1079
|
+
|
|
1080
|
+
try:
|
|
1081
|
+
self._port.reset_input_buffer()
|
|
1082
|
+
except Exception as reset_exc:
|
|
1083
|
+
logger.debug("reset_input_buffer failed between retries: %s", reset_exc,)
|
|
1084
|
+
|
|
1085
|
+
time.sleep(retry_delay)
|
|
1086
|
+
continue
|
|
1087
|
+
|
|
1088
|
+
if not crc_error:
|
|
1055
1089
|
success = True
|
|
1056
1090
|
logger.debug("Page %s sent successfully", page_idx)
|
|
1091
|
+
|
|
1057
1092
|
else:
|
|
1058
1093
|
retry_count += 1
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1094
|
+
|
|
1095
|
+
logger.error("Page %s CRC mismatch! Retry %s/%s", page_idx, retry_count, max_retries,)
|
|
1096
|
+
|
|
1097
|
+
if retry_count >= max_retries:
|
|
1098
|
+
logger.critical("Failed to send page %s after %s attempts",page_idx, max_retries,)
|
|
1099
|
+
raise FlashToolError(
|
|
1100
|
+
f"Failed to send page {page_idx} "
|
|
1101
|
+
f"after {max_retries} attempts"
|
|
1102
|
+
)
|
|
1103
|
+
|
|
1104
|
+
time.sleep(retry_delay)
|
|
1063
1105
|
|
|
1064
1106
|
logger.info(" Done uploading!")
|
|
@@ -368,11 +368,11 @@ class DataStreamingMixin:
|
|
|
368
368
|
degrees = int(angle_deg)
|
|
369
369
|
remaining = angle_deg - degrees
|
|
370
370
|
minutes = int(remaining * 60)
|
|
371
|
-
seconds =
|
|
371
|
+
seconds = round((remaining * 60 - minutes) * 60, 2)
|
|
372
372
|
|
|
373
373
|
logger.info(
|
|
374
374
|
f"[{ans_angle}]: {degrees:>3}{DEGREE_SIGN} "
|
|
375
|
-
f"{minutes:02d}' {seconds:
|
|
375
|
+
f"{minutes:02d}' {seconds:05.2f}\""
|
|
376
376
|
)
|
|
377
377
|
|
|
378
378
|
return ans_angle, [degrees, minutes, seconds]
|
|
@@ -464,14 +464,14 @@ class DataStreamingMixin:
|
|
|
464
464
|
degrees = int(angle_deg)
|
|
465
465
|
remaining = angle_deg - degrees
|
|
466
466
|
minutes = int(remaining * 60)
|
|
467
|
-
seconds =
|
|
467
|
+
seconds = round((remaining * 60 - minutes) * 60, 2)
|
|
468
468
|
|
|
469
469
|
crc_ok = (expected_crc == received_crc)
|
|
470
470
|
status = "OK" if crc_ok else "ERR"
|
|
471
471
|
|
|
472
472
|
logger.info(
|
|
473
473
|
f"[{angle_value}]: {degrees:>3}{DEGREE_SIGN} "
|
|
474
|
-
f"{minutes:02d}' {seconds:
|
|
474
|
+
f"{minutes:02d}' {seconds:05.2f}\"\n"
|
|
475
475
|
f"nE:{nE:01X} nW:{nW:01X} CRC:{received_crc:02X} "
|
|
476
476
|
f"({status})"
|
|
477
477
|
)
|
|
@@ -88,14 +88,8 @@ def biss_send_hex(file_path: str, nonce: Optional[int] = None, pbar: Optional[An
|
|
|
88
88
|
logger.info("Nonce: %s", nonce)
|
|
89
89
|
|
|
90
90
|
ft.biss_set_bank(BiSSBank.BISS_BANK_SERV)
|
|
91
|
-
ft.biss_set_bank(BiSSBank.BISS_BANK_SERV)
|
|
92
|
-
|
|
93
91
|
ft.biss_write_word(BiSSBank.NONCE_REG_INDEX, nonce)
|
|
94
|
-
|
|
95
|
-
ft.biss_write_word(BiSSBank.PAGENUM_REG_INDEX, page_numbers[0])
|
|
96
|
-
# print(page_numbers[0])
|
|
97
|
-
# ft.biss_read_registers(BISS_BANK_SERV)
|
|
98
|
-
# print('=====')
|
|
92
|
+
|
|
99
93
|
ft.send_data_to_device(pages, crc_values, page_numbers, START_PAGE, END_PAGE, pbar)
|
|
100
94
|
ft.biss_read_flags()
|
|
101
95
|
sleep(0.2)
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "lenz-flashtool"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "FlashTool library for BiSS C Firmware Update and Calibration by LENZ Encoders"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{name = "LENZ ENCODERS", email = "devs@lenzencoders.com"}]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|