This package has been deprecated

Author message:

this package has been deprecated

usbdevice

1.1.0 • Public • Published

usbdevice

⚡️ a higher level abstraction for communicating with usb devices

Installation

This library is backed by the node-usb library, and in turn libusb. Therefore, if you're running Linux, you'll need libudev to build libusb. On Ubuntu/Debian run this: sudo apt-get install build-essential libudev-dev.

As this library uses ES2015 features, you'll need at least Node v5.7.0. You might be able to get it to work on lower versions, but I will not be supporting them unfortunately.

Then, just run:

npm install usbdevice --save

Recommended Usage

When I wrote usbdevice, I designed it to be something you would subclass with an object representing the kind of device you were interacting with. Consider something like this as a crude example:

class XboxController extends USBDevice {
  constructor () {
    super(vendorId, productId);
  }
}

API

new USBDevice(vendorId, productId);

Initialises a USB device. I recommend consulting your device manual or developer guide to find the vendor ID and product ID for your device.

.in

A property containing an array of all in endpoints returned when connecting to a device. Will be an empty array before .connect() is called.

.out

A property containing an array of all out endpoints returned when connecting to a device. Will be an empty array before .connect() is called.

.current.in

The index of the current in endpoint to send commands to. Defaults to 0.

.current.out

The index of the current out endpoint to send commands to. Defaults to 0.

.connect();

Connects to the chosen USB device.

.command(command);

Sends a raw command (provided as a string) to a USB device.

.stream();

Returns a writable stream for writing raw data to the USB device. This is a standard Node writiable stream, so normal Stream semantics apply here.

.disconnect();

Disconnects from the chosen USB device.

Readme

Keywords

none

Package Sidebar

Install

npm i usbdevice

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • xadamy