Here’s a collation of steps to setup a U3 LabJack device on Linux, in this case Ubuntu 20.04.
Download tar ball
Downloaded the Linux x86_64 Release Linux 64-bit Installer Package from:
Extract and Install
Extract
$ tar -xzf labjack_ljm_software_2019_07_16_x86_64tar.gz
$ ls -al
labjack_ljm_software_2019_07_16_x86_64
labjack_ljm_software_2019_07_16_x86_64tar.gz
Install
$ cd labjack_ljm_software_2019_07_16_x86_64
$ sudo ./labjack_ljm_installer.run
[sudo] password for user:
Creating directory labjack_ljm_software
Verifying archive integrity... All good.
Uncompressing LabJack software for T4s, T7s, and Digits for Linux x86_64.......................................................................................................................................................................................................................................................................
Installing libLabJackM.so.1.20.1 to /usr/local/lib... done.
Installing LabJackM.h to /usr/local/include... done.
Installing constants files to /usr/local/share... done.
Installing labjack_kipling to /opt... done.
Installing command line shortcut labjack_kipling to /usr/local/bin... done.
Registering with application launcher... done.
/usr/local/lib >> /etc/ld.so.conf
Adding LabJack device rules... done.
Restarting the device rules... done.
Install finished. Please check out the README for usage help.
If you have any LabJack devices connected, please disconnect and
reconnect them now for device rule changes to take effect.
Verify
Plug in your device (U3 JabJack) to USB port and list /var/log/syslog looking for LabJack U3 to ensure it is found, as below.
$ tail /var/log/syslog
May 3 11:33:50 laptop systemd[5916]: tracker-extract.service: Succeeded.
May 3 11:33:51 laptop kernel: [15761.633639] usb 3-3: new full-speed USB device number 6 using xhci_hcd
May 3 11:33:51 laptop kernel: [15761.782937] usb 3-3: New USB device found, idVendor=0cd5, idProduct=0003, bcdDevice= 0.00
May 3 11:33:51 laptop-01-ub kernel: [15761.782942] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
May 3 11:33:51 laptop kernel: [15761.782944] usb 3-3: Product: LabJack U3
May 3 11:33:51 laptop kernel: [15761.782947] usb 3-3: Manufacturer: LabJack
Install ExoDriver
The above software install does not install all requirements. The exodriver is also required for usb control from Python, and is detailed here:
$ sudo apt-get install build-essential
... output removed
$ sudo apt-get install libusb-1.0-0-dev
... output removed
$ sudo apt-get install git-core
... output removed
$ git clone https://github.com/labjack/exodriver.git
Cloning into 'exodriver'...
remote: Enumerating objects: 1044, done.
remote: Counting objects: 100% (48/48), done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 1044 (delta 23), reused 19 (delta 10), pack-reused 996
Receiving objects: 100% (1044/1044), 378.59 KiB | 3.08 MiB/s, done.
Resolving deltas: 100% (615/615), done.
$ cd exodriver/
$ sudo ./install.sh
Making..
rm -f liblabjackusb.so.2.7.0 *.o *~
cc -fPIC -g -Wall -c labjackusb.c
cc -shared -Wl,-soname,liblabjackusb.so -o liblabjackusb.so.2.7.0 labjackusb.o -lusb-1.0 -lc
Installing..
test -z /usr/local/lib || mkdir -p /usr/local/lib
install liblabjackusb.so.2.7.0 /usr/local/lib
test -z /usr/local/include || mkdir -p /usr/local/include
install labjackusb.h /usr/local/include
ldconfig
Adding 90-labjack.rules to /lib/udev/rules.d..
Restarting the rules..
Install finished. Thank you for choosing LabJack.
If you have any LabJack devices connected, please disconnect and reconnect them now for device rule changes to take effect.
If you do not install or build it, you end up with this error if you try to open a device in Python
~$ python3
Python 3.8.10 (default, Mar 13 2023, 10:26:41)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import u3
<class 'LabJackPython.LabJackException'>: Could not load the Exodriver driver. Ethernet connectivity only.
Check that the Exodriver is installed, and the permissions are set correctly.
The error message was: liblabjackusb.so: cannot open shared object file: No such file or directory
>>> quit()
Install Python Library
Install the python library as per:
$ python3 -m pip install LabJackPython
Collecting LabJackPython
Downloading LabJackPython-2.1.0-py2.py3-none-any.whl (115 kB)
|████████████████████████████████| 115 kB 2.2 MB/s
Installing collected packages: LabJackPython
Successfully installed LabJackPython-2.1.0
If you installed without sudo, you’re library will be in your .local folder.
Find the u3.py file like this
$ find ~ | grep u3.py
/home/user/.local/lib/python3.8/site-packages/u3.py
Open it to have a look, or see it on the github repo
https://github.com/labjack/LabJackPython/blob/master/src/u3.py
Run python3 interpreter and verify you can communicate with your device by instantiating a U3() class, reading an analog input (default state of pins, so we can avoid configuring them at this point) and printing the temperature.
$ python3
Python 3.8.10 (default, Mar 13 2023, 10:26:41)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import u3
>>> d = u3.U3()
>>> print (d.getAIN(4))
0.305592048
>>> print(d.getTemperature())
303.5464268177748
>>> d.close()