0

私はDelcomUSBライトを持っています-私がnode.jsから制御しようとしているビルドライト(http://www.delcomproducts.com/products_USBLMP.asp)を考えてください(それが何か違いがある場合はUbuntuで実行しています)

node-usb(https://github.com/schakko/node-usb)を使用しており、デバイスを接続して要求できます。「フラッシュ」することもできますが(最初に接続したときと同じように)、色を変更することはもちろん、点灯したままにすることもできません。

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);

これを実行すると、デバイスがあることを通知し、それを要求し、点滅さえしますが、オンのままにはなりません。

次にどこに目を向けるべきかについて何か考えはありますか?

Node.jsがオフになり、「フラッシュ」がコンピューターがUSBポートを再び制御することと関係がありますか?

4

1 に答える 1

0

ここにいくつかの更新されたコードがあります:

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)

そして、outuptは次のとおりです。

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

0x12と0xc8を設定すると、ライトが点滅/点滅しますが、USBドライバーを制御できないと思います

于 2013-03-26T21:07:22.743 に答える