Know the endpoint of a USB device

Is there a bash command, program, or libusb function (although I didn't find it) that tells me which endpoints the USB device's OUT or IN endpoints are?

For example, the bNumEndpoints of the libusb_interface_descriptor library (from the libusb1.0 library) shows that my usb drive has 3 endpoints, but how can I find out what is their id number?

+6
source share
2 answers

I finally found the answer in lubusb-1.0. This is not really a function, but a structure field:

uint8_t libusb_endpoint_descriptor :: bEndpointAddress

The endpoint address described by this descriptor.

Bits 0: 3 is the endpoint number. Bits 4: 6 are reserved. Bit 7 indicates the direction, see libusb_endpoint_direction.

For each interface for the USB drive, I just needed to write these lines to display the available endpoints:

cout<<"Number of endpoints: "<<(int)interdesc->bNumEndpoints<<endl; for(int k=0; k<(int)interdesc->bNumEndpoints; k++) { epdesc = &interdesc->endpoint[k]; cout<<"Descriptor Type: "<<(int)epdesc->bDescriptorType<<endl; cout<<"EP Address: "<<(int)epdesc->bEndpointAddress<<endl; } 

Where epdesc is libusb_endpoint_descriptor and interdesc is libusb_interface_descriptor.

+4
source

After you have declared the device, launch it (where $ represents the terminal entry point):

 $ sudo lsusb -v -d 16c0:05df 

Where 16c0: 05df are the identifiers of your supplier and product, separated by a colon. (If you do not know this, enter lsusb and find out which device belongs to you by disconnecting and restarting lsusb)

If you are confused, use the lsusb man page:

http://linux.die.net/man/8/lsusb

Then, as soon as your description appears, find the line labeled bEndpointAddress and the hex code will be the endpoint for this particular report.

+8
source

Source: https://habr.com/ru/post/944476/


All Articles