LJFuse (Experimental / Not Released / Unsupported)
LJFuse was an experimental project that is now inactive and unsupported.
LJFuse Overview
LJFuse is a file I/O interface. It makes communicating with a LabJack device simple on Linux and Mac OS X. Really simple. Trivial, really.
Introduction
It's been said that everything's a file in UNIX. LJFuse adopts that philosophy and makes the connections on a LabJack device into files on the filesystem. To do so, it uses FUSE on Linux and MacFUSE on Mac OS X. p. For example, to read analog input AIN0, read a file named "AIN0".
For example, to read analog input AIN0, read a file named "AIN0".
$ cat MyU6/connection/AIN0
3.300
To set DAC0 to 2.4V, write "2.4" to a file named "DAC0".
$ echo 2.4 > MyU6/connection/DAC0
$ cat MyU6/connection/DAC0 # Read the DAC0 to verify it was set
2.400
To set FIO0 to digital output high, write a "1" to "FIO0".
$ echo 1 > MyU6/connection/FIO0-dir # Set the direction to output
$ echo 1 > MyU6/connection/FIO0 # Set the state to output high
$ cat MyU6/connection/FIO0 # Read the value back
1
You can do this from any program that knows how read and write files. Your program doesn't need to know about USB communication, drivers, or the LabJack API. The details are hidden by LJFuse.
Quickstart
Check the requirements (in short, a working LabJackPython installation on Linux or Mac OS X), and download the source code for LJFuse from GitHub. Click the “ZIP” or "Download Source" button on the GitHub page to download.
Note: LJFuse was built with Python2. One user updated the LJFuse source to work with Python3. The updated (unofficial) user source code can be found here: http://ryniker.org/LabJack/ljfuse.py
Connect a LabJack and run LJFuse like this:
$ python ljfuse.py
After LJFuse starts, change to the “root-ljfuse/” directory it created and look around:$ cd root-ljfuse/
$ ls
HOW_TO_UNMOUNT.txt My U6/ README.txt
There are “README.txt” files in every subdirectory with context-specific help.
When done, unmount LJFuse. The file “HOW_TO_UNMOUNT.txt” has instructions.$ cat HOW_TO_UNMOUNT.txt
Requirements
A U3, U6, or UE9 over USB with the latest firmware. The U3 requires 1.26 or higher; the U6 requires 1.15; and the UE9 requires Control firmware 2.13 and Comm firmware 1.5. Check the beta folders of the firmware section if the release version doesn’t meet the requirements.
Exodriver, the Linux and Mac OS X driver
On Mac OS X, LJFuse requires MacFUSE. On Linux, LJFuse uses the kernel’s fuse implementation.
LJSocket is not required, but LJFuse will automatically access LabJack devices opened by LJSocket. On Mac OS X, LJSocket also has the benefit of allowing LJFuse to run in the background (instead of tying up a terminal window).
Running
Plug in a U3, U6, or UE9 and run:$ python ljfuse.py
On Mac OS X, it will print$ python ljfuse.py
Making directory root-ljfuse for LJFuse
Mounting LJFuse at root-ljfuse.
When done, eject it from the Finder or run `umount LJFuse' (without quotes).
$
On Linux, it will print$ python ljfuse.py
Making directory root-ljfuse for LJFuse
Mounting LJFuse at root-ljfuse.
Unmount it with `fusermount -u root-ljfuse' (without quotes).
$
In either case, change to the “root-ljfuse/” directory and look around. There are “README.txt” files in every subdirectory with context-specific help.$ cd root-ljfuse/
$ ls
HOW_TO_UNMOUNT.txt My U6/ README.txt
Example session
In this session, we have a U3-HV and U6 connected when running LJFuse:$ python ljfuse.py
Making directory root-ljfuse for LJFuse
Mounting LJFuse at root-ljfuse.
When done, eject it from the Finder or run `umount LJFuse' (without quotes).
$ cd root-ljfuse/
$ ls
HOW_TO_UNMOUNT.txt My U3-HV/ My U6/ README.txt
LJFuse made two directories, one for the U3-HV and one for the U6. It also made two text files with documentation.
You can rename a device by renaming its directory. The name of the device is saved in its flash memory:$ mv "My U3-HV" "Marcel"
$ ls
HOW_TO_UNMOUNT.txt Marcel/ My U6/ README.txt
$ mv "My U6" MyU6
$ ls
HOW_TO_UNMOUNT.txt Marcel/ MyU6/ README.txt
Inside a device’s subdirectory, there are files relating to the device’s attributes:$ cd MyU6/
$ ls
README.txt firmwareVersion serialNumber
connection/ modbus/
$ cat firmwareVersion
1.15
The “connection/” subdirectory is the most interesting. It contains files for the different connections on the device.$ cd connection/
$ ls
AIN0 DAC0 FIO1 FIO3 FIO5 FIO7
AIN1 DAC1 FIO1-dir FIO3-dir FIO5-dir FIO7-dir
AIN2 FIO0 FIO2 FIO4 FIO6 README.txt
AIN3 FIO0-dir FIO2-dir FIO4-dir FIO6-dir
Wire a jumper from DAC0 to AIN0 and run:$ echo 1.5 > DAC0 # Set DAC0 to 1.5V
$ cat DAC0 # Verify that it set
1.500
$ cat AIN0 # Read AIN0
1.499
Connect an LED from FIO2 to GND (short side in GND) and toggle it:$ cat FIO2-dir # Check the direction of FIO2
0
$ echo 1 > FIO2-dir # Set FIO2 to output
$ cat FIO2-dir # Verify the direction changed
1
$ echo 1 > FIO2 # Set FIO2 high, turning LED on
$ echo 0 > FIO2 # Set FIO2 low, turning LED off
$ while true # Show off a little
> do # Toggle the LED once per second
> echo 1 > FIO2
> sleep 1
> echo 0 > FIO2
> sleep 1
> done
^C # Hit Ctrl-C to quit
We hope these examples demonstrate how quickly and easy LJFuse makes it to communicate with your LabJack.
Shell tricks
The shell can operate on the files in the “connection/” directory to ask interesting questions. For example, which FIO connections are set to digital output?$ grep 1 FIO?-dir
FIO0-dir:1
FIO2-dir:1
Answer: FIO0 and FIO2. Here’s how to set them all to digital output:$ for fiodir in FIO?-dir
> do
> echo 1 > $fiodir
> done
Verify that it worked:$ grep 1 FIO?-dir
FIO0-dir:1
FIO1-dir:1
FIO2-dir:1
FIO3-dir:1
FIO4-dir:1
FIO5-dir:1
FIO6-dir:1
FIO7-dir:1
Here’s how to ask if a value is above a threshold. Carrying on with a previous example, wire a jumper connecting DAC0 to AIN0.$ cat DAC0
1.500
$ cat AIN0
1.499
$ THRESHOLD=1.6
$ AIN0=$(cat AIN0)
$ if [ $(echo "$AIN0 > $THRESHOLD" | bc) -eq 1 ]
> then
> echo "AIN0: $AIN0 above threshold $THRESHOLD"
> else
> echo "AIN0: $AIN0 below threshold $THRESHOLD"
> fi
AIN0: 1.499 below threshold 1.6
$ echo 2.0 > DAC0
$ cat DAC0
2.000
$ cat AIN0
1.999
$ AIN0=$(cat AIN0)
$ if [ $(echo "$AIN0 > $THRESHOLD" | bc) -eq 1 ]
> then
> echo "AIN0: $AIN0 above threshold $THRESHOLD"
> else
> echo "AIN0: $AIN0 below threshold $THRESHOLD"
> fi
AIN0: 1.999 above threshold 1.6
Exiting and unmounting LJFuse
To stop LJFuse, all applications and terminal windows must exit the LJFuse “root-ljfuse/” directory and its subdirectories.
$ pwd
/path/to/LJFuse/root-ljfuse/MyU6/connection
$ cd ../../..
$ pwd
/path/to/LJFuse
On Linux run:
$ fusermount -u root-ljfuse
On Mac OS X, find the LJFuse icon in the Finder and eject it. You could also run:
$ umount LJFuse
If unmounting returns an error, double check that all applications and terminal windows have exited LJFuse directories. Since 10.6, the Mac OS X Finder will report which application is using a volume when trying to eject it.
LabVIEW examples
The following examples illustrate how to
Read AIN0 once per second and log timestamp and value
Toggle an LED on FIO0