npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

linux-gpib

v1.1.1

Published

Linux GPIB bindings

Downloads

4

Readme

Linux GPIB

The brand new General Purpose Interface Bus (GPIB, IEC-625-Bus), introduced by Hewlet-Packard in the late 1960s, can be accessed via linux-gpib. This module offers native bindings to the very fundamental read and write methods (ibrd() and ibwrt()). So if you want to access your lab bench devices using JavaScript, this module will be your solution.

Example

const GPIB = require( 'linux-gpib' );

// Connect to GPIB interface available at /dev/gpib0
const gpib = GPIB( 0 );

// And finally connect to your GPIB device with primary address 20
let specAnalyser = gpib.connect( { pad: 20 } );

// In this example its a Rohde & Schwarz FSP specturm analyser. We want to fetch
// the points recorded on TRACE1. So we transmit the command accordingly the
// user's manual.
specAnalyser.query( 'trac1? trace1' ).then( ( response ) => {

	// The data is transmitted as a string separated by commas. Convert them
	// into floats.
	let data = [];
	response.split(',').forEach( ( v ) => data.push( parseFloat( v ) ) );
	return data;

} ).then( ( data ) => {

	// Output data
	console.log( data );

	// Disconenct from device
	return specAnalyser.disconnect();

} ).catch( ( err ) => {

	// Something went wrong!
	console.error( err.message );

} );

API

The native bindings can be accessed as follows. The API documentation refers to GPIB.

const GPIB = require( 'linux-gpib' );

GPIB

const gpib = GPIB( minor );

Connects to a GPIB adapter available at /dev/gpib[minor] and returns an instance of GPIB.

Class: GPIB

Method: connect

const dev = gpib.connect( device );

Connects to the device described in device and returns an instance of Device.

device has the following properties:

  • pad: Primary GPIB address of the device.
  • sad: (optional) Secondary GPIB address.
  • timeout: (optional) Timeout for I/O operations. Possible values: "TNONE", "T10us", "T30us", "T100us", "T300us", "T1ms", "T3ms", "T10ms", "T30ms", "T100ms", "T300ms", "T1s", "T3s", "T10s", "T30s", "T100s", "T300s", "T1000s". Default: "T300ms".
  • send_eoi: (optional) Assert EOI line with last transmitted byte. Default: true.
  • eos: (optional) end-of-string mode. Default: 0x0.

Method: disconnectAll

gpib.disconnectAll().then( ... );

Disconnects from all connected devices. Returns a promise.

Class: Device

Method: write

dev.write( data ).then( ... );

Sends data to the connected device. Returns a promise. If data is a string, it is just transmitted. If data is an array, each item is transmitted successively, starting with the first item.

Method: read

dev.read().then( ... );

Reads data from the connected device. Returns a promise that will be resolved with the received data.

Method: query

dev.query( data ).then( ... );

Fristly writes data to and then reads data from the connected device. Returns a promise that will be resolved with the received data.

Method: disconnect

dev.disconnect( goToLocalMode ).then( ... );

Disconencts from device. Returns a promise. If goToLocalMode is true (default), it will bring the device back to local mode before disconnecting.

Requirements

Beside a GPIB-capbale measurement instrument you need a GPIB interface that is compatibile with linux-gpib. Furthermore linux-gpib must be installed and the GPIB-device must be fully configured. (Some of them need a firmware downloaded onto the device before beeing used. Google is your friend!)

Node.js must be available in version 4 or later.

Acknowledgement

Special thanks to:

  • 68ec020 for establishing Node.js 12 compatibility.