Connecting to USB device using HID

Viewed 327

I'm using node-hid in an electron application to connect to a USB device. I am able to connect to the device successfully but I am having issues sending messages to it (Get battery status) and am possibly on the wrong track.

Message structure here: enter image description here

Control message I am attempting to send:

enter image description here

The code I am attempting to use:

const HID = require('node-hid')

const devices = HID.devices();
let deviceInfo = devices.find(d => d.vendorId === 8263 && d.productId === 2358);

if( deviceInfo ) {
  var device = new HID.HID( deviceInfo.path );
  // ... use device
  let bytes = Buffer.alloc(8);
  /* set data in the buffer */
  bytes[0] = 0xCFCF;
  bytes[2] = 0x02;
  bytes[4] = 0x1006;
  bytes[6] = 0xA5;
  bytes[7] = 0xA5;
  bytes[8] = 0xBB08;

  let test = device.sendFeatureReport(Array.from(bytes));
}

When running this I get a TypeError: could not send feature report to device error.

Novice with HID connections so any insight appreciated.

0 Answers
Related