Skip to content

Commit 71e4e83

Browse files
georgevigeletteebrahimebrahim
authored andcommitted
- Updated slave communication handling
- Added bulk read from trandmitter and test script - Added DFU support - Added User config support Fixes #432# updated slave communications and update for bootloader pre-commit fixes fixed import and some pre-commit issues
1 parent 677064b commit 71e4e83

5 files changed

Lines changed: 1380 additions & 35 deletions

File tree

examples/legacy/test_multiple_modules.py

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from openlifu.io.LIFUInterface import LIFUInterface
44

55
# set PYTHONPATH=%cd%\src;%PYTHONPATH%
6-
# python notebooks/test_multiple_modules.py
6+
# python examples\legacy\test_multiple_modules.py
77
"""
88
Test script to automate:
99
1. Connect to the device.
@@ -24,8 +24,65 @@
2424
print("Enumerate TX7332 chips")
2525
num_tx_devices = interface.txdevice.enum_tx7332_devices()
2626
if num_tx_devices > 0:
27+
2728
print(f"Number of TX7332 devices found: {num_tx_devices}")
2829

30+
for tx_index in range(num_tx_devices):
31+
module_id = tx_index // 2
32+
device_info = interface.txdevice.write_register(identifier=tx_index, address=0x20 + module_id, value=0x30 + tx_index)
33+
fill_value = 0x40 + tx_index
34+
interface.txdevice.write_block(identifier=tx_index, start_address=0x40, reg_values=[fill_value] * (0x50 - 0x40))
35+
print(f"Wrote to TX{tx_index} (module {module_id}): reg 0x{0x20 + module_id:02X} = 0x{0x30 + tx_index:02X} and block 0x40-0x4F = 0x{fill_value:02X}")
36+
37+
module_count = int(num_tx_devices/2)
38+
for module_index in range(module_count):
39+
40+
ping_result = interface.txdevice.ping(module=module_index)
41+
print(f"Module {module_index} ping result: {ping_result}")
42+
43+
version = interface.txdevice.get_version(module=module_index)
44+
print(f"Module {module_index} Version: {version}")
45+
46+
hw_id = interface.txdevice.get_hardware_id(module=module_index)
47+
print(f"Module {module_index} HW ID: {hw_id}")
48+
49+
echo_data, echo_len = interface.txdevice.echo(module=module_index, echo_data=b'The cat, a sleek silhouette with emerald eyes and whiskers like twin antennae, hopped onto the sunlit windowsill.')
50+
print(f"Module {module_index} Echo Test Returned: {echo_data} STATUS: {'PASS' if echo_data == b'The cat, a sleek silhouette with emerald eyes and whiskers like twin antennae, hopped onto the sunlit windowsill.' else 'FAIL'}")
51+
52+
temp = interface.txdevice.get_temperature(module=module_index)
53+
print(f"Module {module_index} Temperature: {temp}")
54+
55+
ambient = interface.txdevice.get_ambient_temperature(module=module_index)
56+
print(f"Module {module_index} Ambient Temperature: {ambient}")
57+
58+
config = interface.txdevice.read_config(module=module_index)
59+
print(f"Module {module_index} Config (read): {config.get_json_str() if config else None}")
60+
if config is not None:
61+
config.json_data['module_id'] = module_index
62+
updated_config = interface.txdevice.write_config(config, module=module_index)
63+
print(f"Module {module_index} Config (write): {updated_config.get_json_str() if updated_config else None}")
64+
65+
for local_tx in range(2):
66+
tx_index = module_index * 2 + local_tx
67+
expected_reg = 0x30 + tx_index
68+
value = interface.txdevice.read_register(identifier=tx_index, address=0x20 + module_index)
69+
status = 'PASS' if value == expected_reg else 'FAIL'
70+
print(f"Module {module_index} TX{local_tx} (global {tx_index}) reg 0x{0x20 + module_index:02X} = 0x{value:02X} (expected 0x{expected_reg:02X}) {status}")
71+
72+
fill_value = 0x40 + tx_index
73+
block_count = 0x50 - 0x40
74+
read_values = interface.txdevice.read_block(identifier=tx_index, start_address=0x40, count=block_count)
75+
if read_values is None:
76+
print(f"Module {module_index} TX{local_tx} (global {tx_index}) read_block FAIL (no response)")
77+
else:
78+
mismatches = [(0x40 + i, v, fill_value) for i, v in enumerate(read_values) if v != fill_value]
79+
if mismatches:
80+
for addr, got, exp in mismatches:
81+
print(f"Module {module_index} TX{local_tx} (global {tx_index}) reg 0x{addr:02X} = 0x{got:02X} (expected 0x{exp:02X}) FAIL")
82+
else:
83+
print(f"Module {module_index} TX{local_tx} (global {tx_index}) write_block/read_block 0x40-0x4F value=0x{fill_value:02X} PASS")
84+
85+
"""
2986
print("Write Demo Registers to TX7332 chips")
3087
for device_index in range(num_tx_devices):
3188
interface.txdevice.demo_tx7332(device_index)
@@ -40,6 +97,6 @@
4097
print("Failed to stop trigger.")
4198
else:
4299
print("Failed to start trigger.")
43-
100+
"""
44101
else:
45102
raise Exception("No TX7332 devices found.")

src/openlifu/io/LIFUConfig.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@
3333
OW_CMD_GET_TEMP = 0x06
3434
OW_CMD_GET_AMBIENT = 0x07
3535
OW_CMD_ASYNC = 0x09
36+
OW_CMD_USR_CFG = 0x0A
3637
OW_CMD_DFU = 0x0D
3738
OW_CMD_NOP = 0x0E
3839
OW_CMD_RESET = 0x0F
3940

41+
# Firmware Update / Module Commands (starting at 0x10)
42+
OW_CMD_GET_MODULE_COUNT = 0x10
43+
4044
# Controller Commands
4145
OW_CTRL_SET_SWTRIG = 0x13
4246
OW_CTRL_GET_SWTRIG = 0x14
@@ -53,6 +57,7 @@
5357
OW_TX7332_WBLOCK = 0x24
5458
OW_TX7332_VWREG = 0x25
5559
OW_TX7332_VWBLOCK = 0x26
60+
OW_TX7332_RBLOCK = 0x27
5661
OW_TX7332_DEVICE_COUNT = 0x2C
5762
OW_TX7332_DEMO = 0x2D
5863
OW_TX7332_RESET = 0x2F

0 commit comments

Comments
 (0)