Node.js examples for the LJM library. The source code for the LJM Node.js library is also available on GitHub and npm.
Node.js examples for the LJM library. The source code for the LJM Node.js library is also available on GitHub and npm.
LJM stream functions do not work.
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.
Look at the ljm-ffi git repository for more information.
// Load the LJM Library. var ljm_ffi = require('../lib/ljm-ffi'); var ljm = ljm_ffi.load(); // Load a utility function to get the connected device's info. var utils = require('./utils/utils'); var getHandleInfoSync = utils.getHandleInfoSync; // Define a variable that will store data from LJM function calls var data; // Define a variable that will store the device's handle. var handle; // Open the first found T7. data = ljm.LJM_OpenS('LJM_dtT7', 'LJM_ctANY', 'LJM_idANY', 0); // Exit the program if a device was not found. if(data.ljmError !== 0) { console.log('Failed to open a device, please connect a T7 to your computer.'); process.exit(); } else { handle = data.handle; console.log('Connected to device:', getHandleInfoSync(handle)); } // Read the T7's AIN0. data = ljm.LJM_eReadName(handle, 'AIN0', 0); console.log('AIN0', data.Value); // Close the device. data = ljm.LJM_Close(handle);
nodejs_ljm_2016_1_11.zip contains:
.gitignore package.json README.md examples\hello_world.js examples\read_analog_input.js examples\write_analog_output.js examples\misc\hello_world.js examples\utils\utils.js lib\ljm-ffi.js lib\ljm_functions.js lib\type_helpers.js test\basic_ljm_calls.js test\get_ljm_version.js test\test.js test\test_type_helpers.js test\ljm_calls\device_scanning.js test\ljm_calls\ljm_calls.js test\ljm_calls\open_all_testing.js