27 января 2022,
11:57:38 MSK

GSMD написал 24 октября 2006 года в 10:05 (1619 просмотров) Ведет себя неопределенно; открыл 2 темы в форуме.

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:

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:

#define VENDOR_ARGOX 0x1664
#define DEVICE_PT 0xd100
int main(void)
struct usb_bus *bus;
struct usb_device *dev;
int n,m,ret;
char string[256];
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);
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);
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);
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++){
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_close (udev);
else continue;
return 0;

Got no ideas of what am I doing wrong. Anyone faced such a problem, please give a hint.

Последние комментарии
Экология и вегетарианство на благо всем живым существам Планеты.