簡體   English   中英

Ubuntu 12.04 Arm 7 Cortex下的node.js USB InEndpoint錯誤

[英]node.js usb InEndpoint Error under Ubuntu 12.04 Arm 7 Cortex

我目前在內部裝有ARMv7的目標硬件(實用標准)上遇到了麻煩。 當將node.js與usb模塊一起使用時,在我開發它的PC上可以很好地工作,但是現在使用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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM