gpt4 book ai didi

Ubuntu 12.04 Arm 7 Cortex 下的 node.js usb InEndpoint 错误

转载 作者:太空宇宙 更新时间:2023-11-03 23:41:16 28 4
gpt4 key购买 nike

我当前的目标硬件(实用标准)遇到了问题,该硬件内部有 ARMv7。当将node.js与usb模块一起使用时,它在我开发它的电脑下运行良好,但现在在使用usb模块的传输方法读取设备时将其移植到目标时出现问题。

以下是系统的一些详细信息:

Linux utilite-ubuntu-desktop 3.0.35-cm-fx6-4 #123 SMP Thu Sep 12 10:41:30 IST 2013 armv7l armv7l armv7l GNU/Linux
libusb version: 1.0-9 or 1.0-18 (both tested)
node.js version: 0.10.22 (highest 0.10.x version to run on the target)
usb version: latest, (but also others tested downto 2.0)

我收到的错误如下(按此顺序):

{ [Error: **UNKNOWN**] errno: 6 }

{ [Error: **UNKNOWN**] errno: 2 }

我查找了似乎直接来自 libusb (errno.h) 的错误号:

#define ENOFILE 2   /* No such file or directory */
#define ENOENT 2
#define ENXIO 6 /* No such device or address */

我的应用程序源代码是:

var usb = require('usb');

var panel_on_USB = usb.findByIds(conf.USB_VID, conf.USB_PID);
panel_on_USB.open();

console.log("interface :");
console.log(panel_on_USB.interface(0));
console.log("timeout :" + panel_on_USB.timeout);

var panel_interface = panel_on_USB.interface(0);
panel_interface.claim();

console.log("isKernelDriverActive: " + panel_interface.isKernelDriverActive());
console.log("descriptor: " + panel_interface.descriptor);
console.log("panel_interface: " + panel_interface.endpoints);
console.log("LIBUSB_ENDPOINT_IN = " + usb.LIBUSB_ENDPOINT_IN);
console.log("LIBUSB_ENDPOINT_OUT = " + usb.LIBUSB_ENDPOINT_OUT);
console.log(panel_interface.endpoint(1).direction);
console.log(panel_interface.endpoint(2).direction);
console.log(panel_interface.endpoint(131).direction);
console.log(panel_interface.endpoint(132).direction);

输出到控制台:

interface :
{ device:
{ busNumber: 2,
deviceAddress: 3,
deviceDescriptor:
{ bLength: 18,
bDescriptorType: 1,
bcdUSB: 512,
bDeviceClass: 0,
bDeviceSubClass: 0,
bDeviceProtocol: 0,
bMaxPacketSize0: 8,
idVendor: 1240,
idProduct: 62765,
bcdDevice: 0,
iManufacturer: 1,
iProduct: 2,
iSerialNumber: 0,
bNumConfigurations: 1 },
interfaces: [ [Circular] ] },
id: 0,
altSetting: 0,
descriptor:
{ bLength: 9,
bDescriptorType: 4,
bInterfaceNumber: 0,
bAlternateSetting: 0,
bNumEndpoints: 4,
bInterfaceClass: 255,
bInterfaceSubClass: 255,
bInterfaceProtocol: 255,
iInterface: 0,
extra: <Buffer >,
endpoints: [ [Object], [Object], [Object], [Object] ] },
interfaceNumber: 0,
endpoints:
[ { device: [Object],
descriptor: [Object],
address: 1,
transferType: 2 },
{ device: [Object],
descriptor: [Object],
address: 2,
transferType: 2 },
{ device: [Object],
descriptor: [Object],
address: 131,
transferType: 2 },
{ device: [Object],
descriptor: [Object],
address: 132,
transferType: 2 } ] }
timeout :1000
isKernelDriverActive: true
descriptor: [object Object]
panel_interface: [object Object],[object Object],[object Object],[object Object]
LIBUSB_ENDPOINT_IN = 128
LIBUSB_ENDPOINT_OUT = 0
out
out
in
in

产生错误的传输调用:

panel_interface.endpoint(131).transfer(Length_Total_Bytes, function(error, data){
if(error){
//if(conf.Debug_Console_Output){
console.log("USB_receive_Error:");
console.log(error);
//}
}
//...Data Handling done here...//
});

对此有什么想法吗?

最佳答案

出现该问题的原因是实际接收的数据长度与transfer()方法中设置的数据长度不匹配。以下代码解决了该问题,因为在我的情况下,设备(即 wMaxPacketSize)总是将完整的缓冲区返回到主机:

var In_Transfer_Length = 1 * panel_interface.endpoint(131).descriptor.wMaxPacketSize;
panel_interface.endpoint(131).transfer(In_Transfer_Length, function(error, data){

有关此问题的更多详细信息,请参阅 github 上的问题:

https://github.com/nonolith/node-usb/issues/45

关于Ubuntu 12.04 Arm 7 Cortex 下的 node.js usb InEndpoint 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23491696/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com