BiSS CLI Module#
LENZ BiSS Encoder Command Line Interface Module
Provides a command-line interface for interacting with LENZ BiSS encoders through the FlashTool library. Supports all major device operations including register access, command execution, and device information reading.
Features:
Direct register reading (single/bank/range)
Predefined command execution
Raw hex command sending
Serial number and device info reading
Comprehensive error handling
Sending hex files to the encoder
FlashTool mode selection
SPI channel selection
Multi-encoder data reading (SPI-SPI and AB-SPI modes)
FlashTool firmware and bootloader version reading
- Usage:
>>> python -m lenz_flashtool.biss.cli <command> [arguments]
- Example Commands:
>>> python -m lenz_flashtool.biss.cli run >>> python -m lenz_flashtool.biss.cli registers 2 >>> python -m lenz_flashtool.biss.cli reg 0x02 0x10 >>> python -m lenz_flashtool.biss.cli hex 41 82 AA55FF >>> python -m lenz_flashtool.biss.cli readserial >>> python -m lenz_flashtool.biss.cli sendhexfile SAB039_1_1_4.hex >>> python -m lenz_flashtool.biss.cli setmode spi_spi >>> python -m lenz_flashtool.biss.cli setspi channel1 >>> python -m lenz_flashtool.biss.cli read_dual_spi_spi 0.1 >>> python -m lenz_flashtool.biss.cli read_dual_ab_spi 2.0 data.csv >>> python -m lenz_flashtool.biss.cli readversions
- class lenz_flashtool.biss.cli.BiSSCommandLine(flashtool)#
Bases:
objectCommand line interface for BiSS encoder operations
- execute_command(args)#
Execute a command provided via command-line arguments.
Supports a wide range of operations with LENZ BiSS encoders through the FlashTool backend. This function serves as the central dispatcher for interpreting CLI arguments and executing the appropriate action.
- Parameters:
args (
List[str]) – A list of command-line arguments (typically from sys.argv).- Return type:
None
- Supported Commands:
- run
Description: Runs the encoder or initiates default operational mode.
Usage: run
- registers [bank]
Description: Reads all registers in a given bank.
Default bank: 2 (service bank)
- Usage: registers # reads from bank 2
registers 1 # reads from bank 1
- reg <addr> <len>
Description: Reads a specific number of bytes from a register address.
Address and length must be in hex or decimal format.
Usage: reg 0x10 2 # reads 2 bytes from address 0x10
- regb <bank> <addr> <len>
Description: Reads registers from a specific bank and address.
Usage: regb 1 0x10 4 # reads 4 bytes from address 0x10 in bank 1
- hex <addr> <cmd> [data…]
Description: Sends a raw command composed of address, command byte, and optional data bytes.
The data is sent as-is and interpreted by the encoder.
- Usage:
hex 0x00 0x0B 0x10 # turns off power of first channel hex 0x40 0x82 0x11 # reads one byte from register 0x40 hex 0x40 0x82 0x1122 # reads two bytes from 0x40 and 0x41 hex 0x80 0x91 # generic command with no data
- readserial
Description: Reads device serial number, date of manufacture, firmware version, and ID.
Usage: readserial
- readhsi
Description: Reads the hardware status indicator.
Usage: readhsi
- sendhexfile <filename>
Description: Sends a hex file to the encoder.
Usage: sendhexfile <filename.hex>
- setmode <mode>
Description: Sets the FlashTool communication mode for both channels.
- Available modes:
spi_spi - Channel 1: SPI, Channel 2: SPI ab_uart - Channel 1: AB signal, Channel 2: UART spi_uart_irs - Channel 1: SPI, Channel 2: UART for IRS encoders ab_spi - Channel 1: AB signal, Channel 2: SPI default_spi - Default mode: Channel 1: None, Channel 2: SPI
- Usage: setmode spi_spi # sets SPI on both channels
setmode ab_uart # sets AB on channel1, UART on channel2
- setspi <channel>
Description: Selects which SPI channel to use for communication.
- Available channels:
channel1 - Select SPI channel 1 channel2 - Select SPI channel 2
- Usage: setspi channel1 # selects channel 1 for SPI communication
setspi channel2 # selects channel 2 for SPI communication
- read_dual <time>
Description: Reads data from both encoders simultaneously via SPI interface.
Requires FlashTool mode to be set to ‘spi_spi’ using setmode command first.
Reads encoder data for specified duration and displays sample values.
Time parameter specifies reading duration in seconds (can be fractional).
- Usage: read_dual 0.1 # reads data for 100 milliseconds
read_dual 2.0 # reads data for 2 seconds
- readversions
Description: Reads firmware and bootloader versions from the FlashTool device.
Automatically reboots device to bootloader mode, reads versions, and reboots back.
Returns version strings as 8-character hexadecimal values.
Usage: readversions
- <predefined command>
Description: Executes a predefined command from the biss_commands registry.
- Examples:
run ampcalibrate reboot2bl zeroing
Use _show_usage() or run without arguments to list all predefined commands.
- Raises:
ValueError – If arguments are missing or invalid.
FlashToolError – On communication or device interaction failure.
Notes
All addresses and data bytes can be in either hexadecimal (0xNN) or decimal (NN) format.
The method logs each step and captures errors for user-friendly CLI output.
For read_dual command, ensure the encoder is properly connected and powered.
The setmode command must be issued before read_dual when using SPI-SPI configuration.
Some commands require specific hardware configurations and encoder types.
- lenz_flashtool.biss.cli.main()#
Command line entry point, making the library script executes directly: >>> python -m lenz_flashtool.biss.cli <command>