Question

I've got a Delcom USB light - think build light (http://www.delcomproducts.com/products_USBLMP.asp) which I'm trying to control from node.js (running on Ubuntu if that makes any difference)

I'm using node-usb (https://github.com/schakko/node-usb) and I can connect & claim the device. I can even get it to "flash" (just like it does when you first plug it in), but I can't get it to stay lit, let alone change colours

var usb_driver = require("../usb.js"), 
    assert = require('assert');

// setup our vars
var lightVID = 0x0fc5
var lightPID = 0xb080

// Search for ledLight
var usb = usb_driver.create()

var theLight_devices = usb.find_by_vid_and_pid(lightVID, lightPID);
assert.ok((theLight_devices.length >= 1));
console.log("Total lights found: " + theLight_devices.length);  

// get the light
var theLight = theLight_devices[0];

var theLightInterfaces = theLight.getInterfaces();
assert.ok((theLightInterfaces.length >= 1));
console.log("The Light contains interfaces: " + theLightInterfaces.length);

var theLightInterface = theLightInterfaces[0];
console.log("Claiming the LIGHT interface for further actions")
theLightInterface.detachKernelDriver();
//theLightInterface.claim()

console.log(theLightInterface.claim());

// controlTransfer(mixed read|write, _bmRequestTyc8, _bRequest, _wValue, _wIndex, func, timeout);
theLight.controlTransfer(new Buffer(10), 0x88, 0xc8, 0x0635, 0x04, function() {     console.log("LED toggled") }, 0);

When you run this, it tells me there is a device, it claims it, it even flashes, but it just won't stay on.

Any thoughts on where to turn to next?

Would it have anything to do with Node.js turning off and the "flash" is the computer taking control of the USB port again?

Était-ce utile?

La solution

Heres some updated code:

var theLightInterface = theLightInterfaces[0]
console.log("Claiming the LIGHT interface for further actions " + theLightInterface)

for(var inter in theLightInterface){
    console.log("Name: "+ inter)
    console.log("Value: "+ theLightInterface[inter])
}
console.log("Is Active: "+ theLightInterface.isKernelDriverActive() )
console.log("Release Kernel: "+ theLightInterface.detachKernelDriver() )
console.log("Claim Interface: "+ theLightInterface.claim() )

theLight.controlTransfer(new Buffer(0), 0x12, 0xc8, 0x04, 101, function() { console.log("LED toggled") }, 1000)

And the outupt is:

Is Active: 1
Release Kernel: undefined
Claim Interface: undefined

With 0x12 and 0xc8 set, it does make the light blink/flash - but I don't think I have control of the USB driver

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top