Skip to content

1stsetup/nScope-nodejs-addon

Repository files navigation

nScope-nodejs-addon

Addon for NodeJS for the nScope API library

For more information about nScope see https://www.nscope.org/

This repository will create a NodeJS addon based on the nScope library (https://github.com/nLabs-nScope/nScopeAPI.git)

Installation

npm install nscopeapi

Requirements

Example

const nScope = require('nscopeapi');
var nScopeDevice = new nScope.device();
try {
    console.log('API version:', nScopeDevice.check_API_version());
    console.log('API build:', nScopeDevice.check_API_build());
    console.log('FW version:', nScopeDevice.check_FW_version());

    nScopeDevice.open(true);
    console.log("get_power_state:",nScopeDevice.get_power_state());
    console.log("get_power_usage:",nScopeDevice.get_power_usage(),"W");

    for(var channel=1; channel<5; channel++) {
        console.log("get_Ch"+channel+"_on",nScope.get_ChX_on(nScopeDevice, channel));
        console.log("get_Ch"+channel+"_gain",nScope.get_ChX_gain(nScopeDevice, channel));
        console.log("get_Ch"+channel+"_level",nScope.get_ChX_level(nScopeDevice, channel));
    }

    nScope.set_trigger_edge(nScopeDevice, 1);
    nScope.set_sample_rate_in_hz(nScopeDevice, 10.0);
    var request = new nScope.requestClass(nScopeDevice, 10, false);
    request.wait_for_request_finish();
    while (request.has_data()) {
        var data = request.read_data(1);
        console.log("Data:",data);
    }
}
catch(err) {
    console.error("An error occured:"+err);
    console.log("\tlastError:",nScopeDevice.lastError());
    console.log("\tlastErrorStr:",nScopeDevice.lastErrorStr());
}

API Documentation

nScope Module Functions

  • < DeviceObject >device() - Should be called to create a device object.

  • < RequestObject >request(< DeviceObject >device, < Number >numSamples, < Boolean >antiAliased) - Should be called to create a request object.

    • < DeviceObject >device - a device object required by calling device()
    • < Number >numSamples - number of data samples (per channel) to request
    • < Boolean >antiAliased - true: turn on anti-aliasing, false: turn it off

< DeviceObject > Functions

  • < Boolean >open(< Boolean >powerOn) - Open a connected nScope device and initialize it.

    • < Boolean >powerOn - true turns nScope on when first opened, false leaves nScope in its current state.
  • < Boolean >close() - Close and clean a connected nScope device.

  • < Number >check_API_version() - check the version of this API.

  • < Number >check_API_build() - check the build number of this API.

  • < Number >check_FW_version() - check the version of the connected firmware. Will only work when nScope is connected to computer.

  • < Number >get_power_state() - Read the PowerState of the nScope.

  • < Number >get_power_usage() - Read how much power is being used by nScope in watts.

  • < Number >find_firmware_loader() - find the firmware loader.

  • < Number >load_firmware() - load the nScope with current firmware.

  • < Number >write_to_loader() - write the firmware to the loader.

About

Addon for NodeJS for the nScope library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published