openlifu.io.LIFUTXDevice.TxDevice¶
- class openlifu.io.LIFUTXDevice.TxDevice(uart: LIFUUart, module_invert: bool | list[bool] = False)[source]¶
Bases:
object- __init__(uart: LIFUUart, module_invert: bool | list[bool] = False)[source]¶
Initialize the TxDevice.
- Parameters:
uart (LIFUUart) – The LIFUUart instance for communication.
- apply_all_registers()[source]¶
Apply all registers to the TX device.
- Raises:
ValueError – If the device is not connected.
- async_mode(enable: bool | None = None) bool[source]¶
Enable or disable asynchronous mode for the TX device.
- Parameters:
enable (bool | None) – If True, enable async mode; if False, disable it; if None read the current state.
- Returns:
True if async mode is enabled, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs while setting async mode.
- demo_tx7332(identifier: int) bool[source]¶
Sets all TX7332 chip registers with a test waveform.
- Returns:
True if all chips are programmed successfully, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the UART is not connected.
- echo(echo_data=None) tuple[bytes, int][source]¶
Send an echo command to the device with data and receive the same data in response.
- Parameters:
echo_data (bytes) – The data to send (must be a byte array).
- Returns:
The echoed data and its length.
- Return type:
tuple[bytes, int]
- Raises:
ValueError – If the UART is not connected.
TypeError – If the echo_data is not a byte array.
Exception – If an error occurs during the echo process.
- enter_dfu(module: int = 1) bool[source]¶
Perform a soft reset to enter DFU mode on TX device.
- Returns:
True if the reset was successful, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs while resetting the device.
- enum_tx7332_devices(num_devices: int | None = None) int[source]¶
Enumerate TX7332 devices connected to the TX device.
- Parameters:
num_transmitters (int) – The number of transmitters expected to be enumerated. If None, the number of transmitters will be determined from the response. If provided and the number enumerated does not match the expected number, an error will be raised. If the UART is in demo mode, this argument is used to set the number of transmitters for the demo (or set to a default if omitted/None)
- Returns:
number of devices detected.
- Return type:
n_transmitters
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs during enumeration.
- get_ambient_temperature(module: int = 1) float[source]¶
Retrieve the ambient temperature reading from the TX device.
- Returns:
Temperature value in Celsius.
- Return type:
float
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs or the received data length is invalid.
- get_hardware_id(module: int = 1) str[source]¶
Retrieve the hardware ID of the TX device.
- Returns:
Hardware ID in hexadecimal format.
- Return type:
str
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs while retrieving the hardware ID.
- get_temperature(module: int = 1) float[source]¶
Retrieve the temperature reading from the TX device.
- Returns:
Temperature value in Celsius.
- Return type:
float
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs or the received data length is invalid.
- get_trigger()[source]¶
Retrieve the current trigger configuration from the TX device.
- Returns:
The trigger configuration as a dictionary.
- Return type:
dict
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs while fetching the trigger configuration.
- get_trigger_json() dict[source]¶
Start the trigger on the TX device.
- Returns:
True if the trigger was started successfully, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs while starting the trigger.
- get_version(module: int = 1) str[source]¶
Retrieve the firmware version of the TX device.
- Returns:
Firmware version in the format ‘vX.Y.Z’.
- Return type:
str
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs while fetching the version.
- is_connected() bool[source]¶
Check if the TX device is connected.
- Returns:
True if the device is connected, False otherwise.
- Return type:
bool
- ping(module: int = 1) bool[source]¶
Send a ping command to the TX device to verify connectivity.
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs during the ping process.
- property print: None¶
Print TX device information.
- Raises:
None –
- read_register(identifier: int, address: int) int[source]¶
Read a register value from the TX device.
- Parameters:
address (int) – The register address to read.
- Returns:
The value of the register if successful, or 0 on failure.
- Return type:
int
- Raises:
ValueError – If the identifier is not set or is out of range.
Exception – If an unexpected error occurs during the operation.
- set_module_invert(module_invert: bool | List[bool]) None[source]¶
Set the module invert configuration for the TX device.
- Parameters:
module_invert (bool | List[bool]) – The module invert configuration to set.
- set_solution(pulse: Dict, delays: ndarray, apodizations: ndarray, sequence: Dict, trigger_mode: Literal['sequence', 'continuous', 'single'] = 'sequence', profile_index: int = 1, profile_increment: bool = True)[source]¶
Set the solution parameters on the TX device.
- Parameters:
pulse (Dict) – The pulse parameters to set.
delays (list) – The delays to set.
apodizations (list) – The apodizations to set.
sequence (Dict) – The sequence parameters to set.
mode – The trigger mode to use.
profile_index (int) – The pulse profile to use.
profile_increment (bool) – Whether to increment the pulse profile.
- set_trigger(pulse_interval: float, pulse_count: int = 1, pulse_width: int = 20, pulse_train_interval: float = 0.0, pulse_train_count: int = 1, trigger_mode: Literal['sequence', 'continuous', 'single'] = 'sequence', profile_index: int = 0, profile_increment: bool = True) dict[source]¶
Set the trigger configuration on the TX device.
- Parameters:
pulse_interval (float) – The time interval between pulses in seconds.
pulse_count (int) – The number of pulses to generate.
pulse_width (int) – The pulse width in microseconds.
pulse_train_interval (float) – The time interval between pulse trains in seconds.
pulse_train_count (int) – The number of pulse trains to generate.
mode (TriggerModeOpts) – The trigger mode to use.
profile_index (int) – The pulse profile to use.
profile_increment (bool) – Whether to increment the pulse profile.
- set_trigger_json(data=None) dict[source]¶
Set the trigger configuration on the TX device.
- Parameters:
data (dict) – A dictionary containing the trigger configuration.
- Returns:
JSON response from the device.
- Return type:
dict
- Raises:
ValueError – If data is None or the UART is not connected.
Exception – If an error occurs while setting the trigger.
- soft_reset(module: int = 1) bool[source]¶
Perform a soft reset on the TX device.
- Returns:
True if the reset was successful, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs while resetting the device.
- start_trigger() bool[source]¶
Start the trigger on the TX device.
- Returns:
True if the trigger was started successfully, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs while starting the trigger.
- stop_trigger() bool[source]¶
Stop the trigger on the TX device.
This method sends a command to stop the software trigger on the TX device. It checks the device’s connection status and handles errors appropriately.
- Returns:
True if the trigger was successfully stopped, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs during the operation.
- toggle_led(module: int = 1) bool[source]¶
Toggle the LED on the TX device.
- Raises:
ValueError – If the UART is not connected.
Exception – If an error occurs while toggling the LED.
- write_block(identifier: int, start_address: int, reg_values: List[int]) bool[source]¶
Write a block of register values to the TX device.
- Parameters:
start_address (int) – The starting register address to write to.
reg_values (List[int]) – List of register values to write.
- Returns:
True if the block write operation was successful, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the device is not connected, the identifier is invalid, or parameters are out of range.
- write_block_verify(start_address: int, reg_values: List[int]) bool[source]¶
Write a block of register values to the TX device with verification.
- Parameters:
start_address (int) – The starting register address to write to.
reg_values (List[int]) – List of register values to write.
- Returns:
True if the block write operation was successful, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the device is not connected, the identifier is invalid, or parameters are out of range.
- write_register(identifier: int, address: int, value: int) bool[source]¶
Write a value to a register in the TX device.
- Parameters:
address (int) – The register address to write to.
value (int) – The value to write to the register.
- Returns:
True if the write operation was successful, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the device is not connected, or the identifier is invalid.
Exception – If an unexpected error occurs during the operation.
- write_register_verify(address: int, value: int) bool[source]¶
Write a value to a register in the TX device with verification.
- Parameters:
address (int) – The register address to write to.
value (int) – The value to write to the register.
- Returns:
True if the write operation was successful, False otherwise.
- Return type:
bool
- Raises:
ValueError – If the device is not connected, or the identifier is invalid.
Exception – If an unexpected error occurs during the operation.
- write_ti_config_to_tx_device(file_path: str, txchip_id: int) bool[source]¶
Parse a TI configuration file and write the register values to the TX device.
- Parameters:
file_path (str) – Path to the TI configuration file.
txchip_id (int) – The ID of the TX chip to write the registers to.
- Returns:
True if all registers were written successfully, False otherwise.
- Return type:
bool