Cross-platform Java wrapper and examples for the LJM library.
Java_LJM_2017_12_04.zip
12/04/2017
Release
- Up to date with LJM version 1.16.
- Added new examples.
- Added T4 support to examples.
Cross-platform Java wrapper and examples for the LJM library.
javac -classpath .;..\jar\jna.jar;..\jar\ljm.jar EReadName.java
java -classpath .;..\jar\jna.jar;..\jar\ljm.jar EReadName
Mac OS X/Linux
javac -classpath .:../jar/jna.jar:../jar/ljm.jar EReadName.java
java -classpath .:../jar/jna.jar:../jar/ljm.jar EReadName
Refer to the download's README.TXT file for requirements, compile/run instructions, documentation and license information.
With the LJM library, pretty much everything you might want to do with a device is accomplished by writing and/or reading some registers. Look at the device's datasheet (T7 or T4) or the Modbus Map to determine what registers you need to write and read, then use eWriteName (or eWriteNames) to write the desired registers and eReadName (or eReadNames) to read the desired registers.
import java.text.DecimalFormat;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.DoubleByReference;
import com.labjack.LJM;
import com.labjack.LJMException;
public class ReadSerialNumber {
public static void main(final String[] args) {
try {
IntByReference handleRef = new IntByReference(0);
int handle = 0;
//Open first found LabJack
LJM.openS("ANY", "ANY", "ANY", handleRef);
handle = handleRef.getValue();
//Call eReadName to read the serial number from the LabJack.
String name = "SERIAL_NUMBER";
DoubleByReference valueRef = new DoubleByReference(0);
LJM.eReadName(handle, name, valueRef);
System.out.println("\neReadName result: ");
System.out.println(" " + name + " = "
+ new DecimalFormat("#.#").format( valueRef.getValue() ));
}
catch (LJMException le) {
le.printStackTrace();
}
}
}
Java_LJM_2017_12_04.zip contains:
LICENSE.txt README.txt doc\allclasses-frame.html doc\allclasses-noframe.html doc\constant-values.html doc\deprecated-list.html doc\help-doc.html doc\index-all.html doc\index.html doc\overview-tree.html doc\script.js doc\serialized-form.html doc\stylesheet.css doc\com\labjack\LJM.Constants.html doc\com\labjack\LJM.Errors.html doc\com\labjack\LJM.html doc\com\labjack\LJM.LabJackM.html doc\com\labjack\LJMException.html doc\com\labjack\package-frame.html doc\com\labjack\package-summary.html doc\com\labjack\package-tree.html examples\LJMUtilities.java examples\Basic\EAddresses.java examples\Basic\ENames.java examples\Basic\EReadAddress.java examples\Basic\EReadAddresses.java examples\Basic\EReadName.java examples\Basic\EReadNames.java examples\Basic\EWriteAddress.java examples\Basic\EWriteAddresses.java examples\Basic\EWriteName.java examples\Basic\EWriteNames.java examples\More\AIN\DualAINLoop.java examples\More\AIN\SingleAIN.java examples\More\AIN\SingleAINWithConfig.java examples\More\Config\ReadConfig.java examples\More\Config\ReadDeviceNameString.java examples\More\Config\WriteDeviceNameString.java examples\More\Config\WritePowerConfig.java examples\More\DIO\SingleDIORead.java examples\More\DIO\SingleDIOWrite.java examples\More\DIO_EF\DioEfConfig1PwmAnd1Counter.java examples\More\Ethernet\ReadEthernetConfig.java examples\More\Ethernet\ReadEthernetMac.java examples\More\Ethernet\WriteEthernetConfig.java examples\More\I2C\I2CEeprom.java examples\More\ListAll\ListAll.java examples\More\SPI\SPI.java examples\More\Stream\StreamBasic.java examples\More\Stream\StreamBasicWithStreamOut.java examples\More\Stream\StreamBurst.java examples\More\Stream\StreamSequentialAIN.java examples\More\Testing\CRSpeedTest.java examples\More\Watchdog\ReadWatchdogConfig.java examples\More\Watchdog\WriteWatchdogConfig.java examples\More\WiFi\ReadWiFiConfig.java examples\More\WiFi\ReadWiFiMac.java examples\More\WiFi\ReadWiFiRssi.java examples\More\WiFi\WriteWiFiConfig.java jar\jna.jar jar\ljm.jar src\build_ljm.bat src\Manifest.txt src\com\labjack\LJM.java src\com\labjack\LJMException.java