lib/ljm-ffi.js
function createSyncFunction(functionName, functionInfo) {
    return function syncLJMFunction() {
        if(arguments.length != functionInfo.args.length) {
            var errStr = 'Invalid number of arguments.  Should be: ';
            errStr += functionInfo.args.length.toString() + '.  ';
            errStr += 'Given: ' + arguments.length + '.  ';
            errStr += getFunctionArgNames(functionInfo).join(', ');
            errStr += '.';
            console.error('Error in ljm-ffi syncLJMFunction', errStr);
            throw new LJMFFIError(errStr);
        } else {
            // Create an array that will be filled with values to call the
            // LJM function with.
            var funcArgs = [];

            // Parse and fill the function arguments array with data.
            allocateAndFillSyncFunctionArgs(functionInfo, funcArgs, arguments);

            // Execute the synchronous LJM function.
            var ljmFunction = liblabjack[functionName];
            var ljmError = ljmFunction.apply(this, funcArgs);

            // Create an object to be returned.
            var retObj = {
                'ljmError': ljmError,
            };
            if(ljmError !== 0) {
                retObj.errorInfo = modbus_map.getErrorInfo(ljmError);
            }

            // Fill the object being returned with data.
            parseAndStoreSyncFunctionArgs(functionInfo, funcArgs, retObj);
            return retObj;
        }
    };
}
function createSyncFunction(functionName, functionInfo) {
    return function syncLJMFunction() {
        if(arguments.length != functionInfo.args.length) {
            var errStr = 'Invalid number of arguments.  Should be: ';
            errStr += functionInfo.args.length.toString() + '.  ';
            errStr += 'Given: ' + arguments.length + '.  ';
            errStr += getFunctionArgNames(functionInfo).join(', ');
            errStr += '.';
            console.error('Error in ljm-ffi syncLJMFunction', errStr);
            throw new LJMFFIError(errStr);
        } else {
            // Create an array that will be filled with values to call the
            // LJM function with.
            var funcArgs = [];

            // Parse and fill the function arguments array with data.
            allocateAndFillSyncFunctionArgs(functionInfo, funcArgs, arguments);

            // Execute the synchronous LJM function.
            var ljmFunction = liblabjack[functionName];
            var ljmError = ljmFunction.apply(this, funcArgs);

            // Create an object to be returned.
            var retObj = {
                'ljmError': ljmError,
            };
            if(ljmError !== 0) {
                retObj.errorInfo = modbus_map.getErrorInfo(ljmError);
            }

            // Fill the object being returned with data.
            parseAndStoreSyncFunctionArgs(functionInfo, funcArgs, retObj);
            return retObj;
        }
    };
}
function createSyncFunction ( functionName , functionInfo ) { return function syncLJMFunction ( ) { if ( arguments . length != functionInfo . args . length ) { var errStr = 'Invalid number of arguments.  Should be: ' ; errStr += functionInfo . args . length . toString ( ) + '.  ' ; errStr += 'Given: ' + arguments . length + '.  ' ; errStr += getFunctionArgNames ( functionInfo ) . join ( ', ' ) ; errStr += '.' ; console . error ( 'Error in ljm-ffi syncLJMFunction' , errStr ) ; throw new LJMFFIError ( errStr ) ; } else { // Create an array that will be filled with values to call the // LJM function with. var funcArgs = [ ] ; // Parse and fill the function arguments array with data. allocateAndFillSyncFunctionArgs ( functionInfo , funcArgs , arguments ) ; // Execute the synchronous LJM function. var ljmFunction = liblabjack [ functionName ] ; var ljmError = ljmFunction . apply ( this , funcArgs ) ; // Create an object to be returned. var retObj = { 'ljmError' : ljmError , } ; if ( ljmError !== 0 ) { retObj . errorInfo = modbus_map . getErrorInfo ( ljmError ) ; } // Fill the object being returned with data. parseAndStoreSyncFunctionArgs ( functionInfo , funcArgs , retObj ) ; return retObj ; } } ; }
Define a function that creates functions that can call LJM synchronously.
Define a function that creates functions that can call LJM synchronously .