New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@josephdadams/usbrelay

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@josephdadams/usbrelay

Control USB HID Relays from NodeJS.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

USB Relay

Control simple USB HID Relays using Node JS like this one:

picture alt

To install

npm i @josephdadams/usbrelay

To use:

const USBRelay = require("@josephdadams/usbrelay");
const relay = new USBRelay(); //gets the first connected relay

To use a specific relay, specify a HID path:

const relay = new USBRelay(path);

Get connected relays:

USBRelay.Relays; //returns an array with HID data including paths

Set relay state:

relay.setState(1, true); // turns Relay 1 of the device on
relay.setState(1, false); // turns Relay 1 of the device off

Relay numbers are NOT zero-based, so if you want to refer to Relay #1, use 1.

To turn all relays off:

relay.setState(0, false); // relay number 0 references all relays of the device

To turn a relay on, wait 1 second, and then turn off:

relay.setState(1, true);

setTimeout(function () {
    relay.setState(1, false);
}, 1000);

FAQs

Package last updated on 14 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc