Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-24-2006, 02:07 AM
|
#1
|
Member
Registered: Dec 2005
Distribution: Gentoo
Posts: 87
Rep:
|
usb_bulk_read() - open error 11 Resource temporarily unavailable
I've succeeded with usb_bulk_write() but can't utilize usb_bulk_read(). It returns an error open error 11 Resource temporarily unavailable.
Here is the output of
cat /prog/bus/usb/devices:
Code:
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=16 #Cfgs= 1
P: Vendor=1664 ProdID=d100 Rev= 2.00
S: Manufacturer=Argox Informations
S: Product=CRD -10
S: SerialNumber=60227075
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=03(HID ) Sub=00 Prot=00 Driver=(none)
E: Ad=82(I) Atr=03(Int.) MxPS= 64 Ivl=1ms
E: Ad=02(O) Atr=03(Int.) MxPS= 64 Ivl=1ms
The source code that utilizes the mentioned functions:
Code:
#include <usbpp.h>
#include <stdio.h>
#include <iostream.h>
#include <errno.h>
#define VENDOR_ARGOX 0x1664
#define DEVICE_PT 0xd100
int main(void)
{
struct usb_bus *bus;
struct usb_device *dev;
int n,m,ret;
usb_init();
char string[256];
n=usb_find_busses();
m=usb_find_devices();
usb_dev_handle *udev;
for (bus = usb_busses; bus; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next) {
if (dev->descriptor.idVendor==VENDOR_ARGOX)
if (dev->descriptor.idProduct==DEVICE_PT){
udev = usb_open(dev);
if (udev) {
printf("found argox_PT dev-%s on bus-%s\n",dev->filename,bus->dirname);
usb_detach_kernel_driver_np(udev, 0);
usb_set_configuration(udev, 1);
if (dev->descriptor.iManufacturer) {
usb_get_string_simple(udev, dev->descriptor.iManufacturer, string, sizeof(string));
if (ret > 0)
printf("- Manufacturer : %s\n", string);
else
printf("- Unable to fetch manufacturer string\n");
}
if (dev->descriptor.iProduct) {
ret = usb_get_string_simple(udev, dev->descriptor.iProduct, string, sizeof(string));
if (ret > 0)
printf("- Product : %s\n", string);
else
printf("- Unable to fetch product string\n");
}
if (dev->descriptor.iSerialNumber) {
ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string));
if (ret > 0)
printf("- Serial Number: %s\n", string);
else
printf("- Unable to fetch serial number string\n");
}
ret = usb_claim_interface(udev,0);
if (ret>=0) printf("device claimed!\n");
else printf("open error %d %s\n", errno, strerror(errno));
unsigned int WRITE=dev->config[0].interface[0].altsetting[0].endpoint[1].bEndpointAddress;
unsigned int READ=dev->config[0].interface[0].altsetting[0].endpoint[0].bEndpointAddress;
char * buff = new char[10];
delete [] buff;
char bufferout[]={0x1b,0x02,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x02,0x1b,0x3f,0x00};
char bufferin[256];
int sizein=dev->config[0].interface[0].altsetting[0].endpoint[1].wMaxPacketSize;
int sizeout=dev->config[0].interface[0].altsetting[0].endpoint[0].wMaxPacketSize;
int pts=dev->config[0].interface[0].altsetting[0].endpoint[0].bInterval;
int i;
printf("WRITE TO %02xh READ FROM %02xh\n SIZEIN %d SIZEOUT %d\n PTS %d\n",WRITE,READ,sizein,sizeout,pts);
for (i=0;i<14;i++){
*(buff+i)=bufferout[i];
ret=usb_interrupt_write(udev, WRITE, buff, 1, 100);
if (ret>=0) printf("buf=%02x, transfered %d bytes \n",*buff+i,ret);
else printf("open error %d %s\n", errno, strerror(errno));
}
for (i=0;i<14;i++){
ret=usb_interrupt_read(udev, READ, buff, 1, 100);
if (ret>=0) {printf("buf=%02x, read %d bytes \n",*buff+i,ret); bufferin[i]=*buff;}
else printf("open error %d %s\n", errno, strerror(errno));
}
for(i=0;i<14;i++) printf("read:%02x \n",bufferin[i]);
usb_release_interface(udev,0);
usb_close (udev);
}}
else continue;
}}
return 0;
}
Got no ideas of what am I doing wrong. Anyone faced such a problem, please give a hint.
|
|
|
All times are GMT -5. The time now is 01:06 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|