首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >USB Light HID控制与Node.JS和节点-usb-闪存只?

USB Light HID控制与Node.JS和节点-usb-闪存只?
EN

Stack Overflow用户
提问于 2013-03-26 14:01:50
回答 1查看 1.8K关注 0票数 0

我有一个Delcom USB灯--想想构建灯(http://www.delcomproducts.com/products_USBLMP.asp),我正试着从node.js控制它(运行在Ubuntu上,如果有什么不同的话)

我正在使用node-usb (https://github.com/schakko/node-usb),我可以连接并认领设备。我甚至可以让它“闪光”(就像你第一次插入它时一样),但我不能让它保持亮起,更不用说改变颜色了。

代码语言:javascript
复制
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端口有关系?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-27 05:07:23

下面是一些更新后的代码:

代码语言:javascript
复制
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)

结果是:

代码语言:javascript
复制
Is Active: 1
Release Kernel: undefined
Claim Interface: undefined

在设置了0x12和0xc8的情况下,它确实会使指示灯闪烁/闪烁-但我不认为我可以控制USB驱动程序

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15630369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档