Python interactive shell for LabJack U3 devices for bench use.
- Interactive shell (
python -m labjack_u3 shell) for bench use, with device discovery, alias management, and digital/analog I/O commands.- Analog input (
AIN) voltage readings. - Analog output (
DAC) voltage control. - Digital I/O (
FIO) control. - USB device discovery.
- Persistent device aliases.
- Analog input (
- Layered device configuration: known devices are stored as
alias/serial-number pairs in
config.ini.
This project is a thin, opinionated layer on top of LabJack's own LabJackPython package, providing an interactive CLI for bench testing.
LabJack already provides Python libraries for communicating with U3 devices. This project does not replace them.
Instead, it provides a small command-line interface for quickly interacting with multiple U3 devices during bench testing.
The main goal is to make common hardware operations available without having to write a Python script for every quick test.
- Python 3.8
- LabJack U3
- LabJack UD driver on Windows or Exodriver on Linux/macOS
- LabJackPython
Windows: install the UD driver from LabJack's
UD Software Installer Downloads
page. This installs LabJackUD.dll and the LJControlPanel utility, which
is useful for confirming that a device is recognized before using this
driver.
Ubuntu / Linux: install the Exodriver from LabJack's
Exodriver Downloads
page. The Exodriver is built from source on Linux and requires the
libusb-1.0 development headers:
sudo apt install build-essential libusb-1.0-0-devFollow the build instructions on the Exodriver downloads page linked
above; the short version is downloading the source, then running
sudo make install from the extracted directory.
LabJackPython is LabJack's own Python package for talking to the U3,
U6, and UE9 over the driver installed in step 1. See LabJack's
LabJackPython
page for details. In most cases it is enough to install it from PyPI:
pip install LabJackPythongit clone https://github.com/PatrickADz/labjack-u3-cli.git
cd labjack-u3-cli
pip install -e .cp config.example.ini config.ini # Linux/macOS
copy config.example.ini config.ini # Windowsconfig.ini is listed in .gitignore, so the serial numbers of the
devices on your bench never end up in the repository. The find and
save shell commands below can populate it for you.
Connect the LabJack U3 devices over USB, then start the shell:
python -m labjack_u3 shelllabjack> find
Found 2 device(s):
serial=320012345
serial=320067890
labjack> save hv 320012345
Saved 'hv' = 320012345 to config.ini
labjack> save lv 320067890
Saved 'lv' = 320067890 to config.ini
labjack> connect hv
Connected to 'hv' (serial 320012345). Active device set.
labjack> connect lv
Connected to 'lv' (serial 320067890). Active device set.
labjack> dac hv 0 2.5
DAC0 on 'hv' set to 2.5 V
labjack> fio lv 4 1
FIO4 on 'lv' set to 1
labjack> adc hv 0
AIN0 on 'hv' reads 1.2300 V
labjack> status
Active device: lv
Connected: ['hv', 'lv']
Known aliases (from config): {'hv': 320012345, 'lv': 320067890}
labjack> exit
Goodbye.
Every hardware command accepts an optional alias as its first argument
(dac hv 0 2.5, fio lv 4 1). If the alias is omitted, the command
targets the currently active device, set by the last connect or use.
Type help inside the shell for the full command list, or
help <command> for the usage of one command.
labjack-u3-cli/
├── labjack_u3/
│ ├── __init__.py # public API (LabJackU3, discover_devices, exceptions)
│ ├── __main__.py # entry point for `python -m labjack_u3`
│ ├── device.py # LabJackU3 wrapper around u3.U3
│ ├── discovery.py # USB bus scan for connected devices
│ ├── config.py # config.ini loading/saving
│ ├── exceptions.py # typed exception hierarchy
│ └── shell.py # interactive cmd.Cmd shell
├── config.example.ini # template for config.ini
├── pyproject.toml
└── LICENSE
MIT. See LICENSE.