Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带Node.JS的USB灯HID控制&;节点usb-仅闪存?_Node.js_Usb_Hid_Light - Fatal编程技术网

带Node.JS的USB灯HID控制&;节点usb-仅闪存?

带Node.JS的USB灯HID控制&;节点usb-仅闪存?,node.js,usb,hid,light,Node.js,Usb,Hid,Light,我有一个Delcom USB light-think build light(),我正试图从node.js控制它(在Ubuntu上运行,如果这有什么不同的话) 我正在使用node usb(),我可以连接并声明设备。我甚至可以让它“闪烁”(就像你第一次插上电源时一样),但我无法让它保持点亮,更不用说改变颜色了 var usb_driver = require("../usb.js"), assert = require('assert'); // setup our vars var

我有一个Delcom USB light-think build light(),我正试图从node.js控制它(在Ubuntu上运行,如果这有什么不同的话)

我正在使用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端口有关?

以下是一些更新的代码:

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)
结果是:

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

设置了0x12和0xc8后,指示灯确实会闪烁/闪烁-但我认为我无法控制USB驱动程序

好吧,首先你应该将逗号替换为分号,而且,在语句的每一个结尾都加上分号是一个好习惯;哈哈,你知道我来自哪里;是必需的;)但对于node,人们似乎不使用它。