Reputation: 125
I have trouble on my current target hardware (utilite standard) which has an ARMv7 internally. When using node.js with the usb module it works well under my pc where I developed it but now there are problems when porting it to the target when reading the device with the transmit-method of the usb module.
here are some details of the system:
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)
The Errors I get are the following (in this order):
{ [Error: **UNKNOWN**] errno: 6 }
or
{ [Error: **UNKNOWN**] errno: 2 }
I looked up the error numbers which seem to come directly from libusb (errno.h):
#define ENOFILE 2 /* No such file or directory */
#define ENOENT 2
#define ENXIO 6 /* No such device or address */
My applications source code is:
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);
Outputs to the console:
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
The transfer call that generates the error:
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...//
});
Any Ideas about this?
Upvotes: 1
Views: 445
Reputation: 125
The problem occured due to a missmatch of actual recieved data length and set data length in the transfer() method. The following code fixed the problem as always a full buffer is returned to the host by the device (which is wMaxPacketSize) in my case:
var In_Transfer_Length = 1 * panel_interface.endpoint(131).descriptor.wMaxPacketSize;
panel_interface.endpoint(131).transfer(In_Transfer_Length, function(error, data){
For more details on this see the issue on github:
https://github.com/nonolith/node-usb/issues/45
Upvotes: 2