porsager / busylight

node library for busylight
50 stars 17 forks source link

Cannot get a specific Busylight attached to system #35

Closed jflkadsjfslkj closed 7 months ago

jflkadsjfslkj commented 9 months ago

I have multiple busylights attached Raspberry Pi 4 with Raspberry Pi OS Bullseye and Node 18 and I want address them individually and not just the first one found. Addressing the first found works great. The README code var busylight = require('busylight').get(path); does nothing.

Does anyone have multiple busylights working?

// List all busylights - interested in the paths
var bl = require('busylight');
console.log(bl.devices(true));

// Using a path from above does not work - no flashing or anything
var busylight1 = require('busylight').get('/dev/hidraw1');

// This works fine for the first busylight found// List all busylights - interested in the paths
//var busylight1 = require('busylight').get();

busylight1.blink(['lime', 'black'], 150);

Output from the console log above

[
  {
    vendorId: 10171,
    productId: 15306,
    path: '/dev/hidraw0',
    serialNumber: '',
    manufacturer: 'PLENOM APS',
    product: 'BUSYLIGHT',
    release: 256,
    interface: 0,
    usagePage: 65280,
    usage: 1
  },
  {
    vendorId: 10171,
    productId: 15306,
    path: '/dev/hidraw1',
    serialNumber: '',
    manufacturer: 'PLENOM APS',
    product: 'BUSYLIGHT',
    release: 256,
    interface: 0,
    usagePage: 65280,
    usage: 1
  }
]
josephdadams commented 7 months ago

I am seeing this also. The .get() works fine, but getting a path does nothing.

jflkadsjfslkj commented 7 months ago

I am seeing this also. The .get() works fine, but getting a path does nothing.

In Issue #31 somebody tries integer values for the path. I have not tried it yet. const bl = require('busylight').get(1);

josephdadams commented 7 months ago

In looking at the code, it expects an options object as the argument for .get(options), like this: { "vendorId": 1240, "productId": 63560 }. When you enumerate the devices, you'll get an array with all of these values, plus more properties.

My guess is that in the hidFinder.js file, it is filtering out the (valid) results, whereas when you just specify .get(), the options argument is undefined and is then replaced with a simple array of valid supported vendorId/productId values (see the supported.json file.) So you get a null assignment instead and then nothing works. But that is just my guess from looking at it and I don't have my devices in front of me to test.

jflkadsjfslkj commented 7 months ago

In looking at the code, it expects an options object as the argument for .get(options), like this: { "vendorId": 1240, "productId": 63560 }

Thanks Joseph, it works great now. The documentation incorrectly refers to a path. var busylight = require('busylight').get(path); In issue #6 the author replies to a post with a path var busylight = require('busylight').get('0001:0005:00');

You are correct with the options object as an argument instead of a string path. Just a path key value pair passed as an argument is enough. This works great:

//var busylight1 = require('busylight').get({"vendorId": 10171, "productId": 15306, "path": '/dev/hidraw2'});
var busylight1 = require('busylight').get({"path": '/dev/hidraw2'});
busylight1.blink(['lime', 'black'], 150);

//var busylight2 = require('busylight').get({"vendorId": 10171, "productId": 15306, "path": '/dev/hidraw3'});
var busylight2 = require('busylight').get({"path": '/dev/hidraw3'});
busylight2.blink(['fuchsia', 'black'], 150);