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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-red-contrib-usbhid-path

v1.3.2

Published

A node-hid wrapper for Node-RED with path-based device selection support

Downloads

56

Readme

node-red-contrib-usbhid-path

A fork of node-red-contrib-usbhid that adds path-based device selection support. This enhancement is particularly useful when working with multiple identical devices that share the same VID/PID.

Credits

This package is based on node-red-contrib-usbhid by @gdziuba. The original package provided the foundation for USB HID communication in Node-RED, and this fork adds path-based device selection capabilities while maintaining compatibility with the original package.

Acknowledgments

Features

  • All the features of the original package
  • Path-based device selection support
  • Non-conflicting node names (uses -p suffix)
  • Device picker in configuration node

Node Types

This package provides three nodes with -p suffix to avoid conflicts with the original package:

  1. hidconfig-p - Configuration node with path-based device selection

    • Configure by VID/PID or device path
    • Built-in device picker shows available devices
    • Shows device paths for easy identification
  2. gethiddevices-p - List available HID devices

    • Lists all connected USB HID devices
    • Includes device paths in the output
    • Useful for device discovery
  3. hiddevice-p - Communicate with HID devices

    • Send and receive data from HID devices
    • Auto-reconnect on device disconnect
    • Three outputs:
      • Output 1: Data received from device
      • Output 2: Error messages
      • Output 3: Connection status updates

Prerequisites

  • Node.js v0.8 - v4.x+
  • Mac OS X 10.8, Linux (kernel 2.6+), and Windows XP+
  • libudev-dev, libusb-1.0-0-dev (if Linux, see Compile below)
  • git

node-hid uses node-pre-gyp to store pre-built binary bundles, so usually no compiler is needed to install.

Platforms we pre-build binaries for:

  • Mac OS X x64: v0.10, v0.12, v4.2.x
  • Windows x64 & x86: v0.10, v0.12, v4.2.x
  • Linux Debian/Ubuntu x64: v4.2.x
  • Raspberry Pi arm: v4.2.x

Installation

From Source

cd ~/.node-red/node-modules
git clone https://github.com/jpkelly/node-red-contrib-usbhid-path.git
cd node-red-contrib-usbhid-path
npm install

Linux USB Permissions

For Linux systems, you need to set up proper USB permissions:

  1. Install required libraries:
sudo apt install libusb-1.0-0 libusb-1.0-0-dev libudev-dev
  1. Create udev rules:
sudo mkdir -p /etc/udev/rules.d
sudo nano /etc/udev/rules.d/85-pure-data.rules
  1. Add the following rules (update KERNEL for your device):
SUBSYSTEM=="input", GROUP="input", MODE="0777"
SUBSYSTEM=="usb", MODE:="777", GROUP="input"
KERNEL=="hidraw*", MODE="0777", GROUP="input"
  1. Set up input group:
sudo groupadd -f input
sudo gpasswd -a $USER input
  1. Reload rules and reboot:
sudo udevadm control --reload-rules
sudo reboot

Usage

  1. Add a hidconfig-p node to configure your device:

    • Enter VID/PID, or
    • Use the device picker to select by path
    • (Optional) Set interface number if needed
  2. Use gethiddevices-p to list available devices:

    • Connect to an inject node to trigger
    • View device details in debug node
  3. Use hiddevice-p to communicate:

    • Configure with a hidconfig-p node
    • Input: Buffer or Array payload
    • Output 1: Received data
    • Output 2: Errors

Connection Status Output

The hiddevice-p node provides real-time connection status through its third output. The status message format is:

{
    topic: "status",
    payload: {
        fill: "green" | "yellow" | "red",  // Status color
        shape: "dot" | "ring",            // Status shape
        text: "connected" | "disconnected" | "reconnecting in Xs"  // Status text
    },
    timestamp: 1234567890  // Timestamp of status change
}

Status indicators:

  • 🟢 Green: Device connected and ready (includes device details)
  • 🟡 Yellow: Attempting to reconnect
  • 🟥 Red: Device disconnected

The connection status includes detailed device information in the payload:

{
    topic: "status",
    payload: {
        fill: "green",
        shape: "dot",
        text: "connected to Barcode Scanner (/dev/hidraw0)",  // Human-readable status
        device: {
            product: "Barcode Scanner",      // Device name if available
            vendorId: 1234,                  // Vendor ID
            productId: 5678,                 // Product ID
            path: "/dev/hidraw0",           // Device path
            serialNumber: "ABC123",          // Serial number if available
            interface: 0                     // Interface number if applicable
        }
    },
    timestamp: 1234567890
}

Example Flow: Status Display

Here's an example of how to use the connection status output with a UI LED and text display:

[
    {
        "id": "015f81a5e59b3ab8",
        "type": "function",
        "name": "Parse Connection Status",
        "func": "// Log incoming message for debugging\nnode.log(\"Incoming message: \" + JSON.stringify(msg));\n\n// Get the status from the incoming message\nconst status = msg.payload;\n\nif (status && status.fill) {\n    // Create two separate messages\n    const ledMsg = { payload: 3 };  // Default to red\n    const textMsg = { payload: status.text };  // Use the actual status text\n\n    // Set LED color based on status\n    switch(status.fill) {\n        case \"green\":\n            ledMsg.payload = 1;  // Green\n            break;\n        case \"yellow\":\n            ledMsg.payload = 2;  // Yellow\n            break;\n        case \"red\":\n            ledMsg.payload = 3;  // Red\n            break;\n    }\n    \n    node.log(\"Setting LED state to: \" + ledMsg.payload);\n    node.log(\"Setting status text to: \" + textMsg.payload);\n\n    // Return array of messages [LED message, Text message]\n    return [ledMsg, textMsg];\n} else {\n    // Handle invalid status\n    return [{payload: 3}, {payload: \"Unknown status\"}];\n}",
        "outputs": 2,
        "noerr": 0
    }
]

To use this example:

  1. Connect the third output of your hiddevice-p node to the function node
  2. Add a FlowFuse Dashboard UI LED widget to the first output of the function
    • Configure LED colors: 1=Green, 2=Yellow, 3=Red
  3. Add a FlowFuse Dashboard text widget to the second output
    • This will display the connection status text

Example Flow

See the included examples/getStarted.json for a complete working example flow.

Important Notes

  • When using with input devices (keyboards, mice, etc.), be aware that the node may take exclusive control
  • For system input devices, prefer using path-based selection to ensure you connect to the right device
  • Multiple identical devices can be distinguished by their paths

For more information about node-hid, visit: https://github.com/node-hid/node-hid