Hi all, I am using GET_DEVICE_ID request sepcified in <USB Device class Definition for Printing Devices> to get the printer's description. I use usb_control_msg to get the id-string. But something just does strange. I use HP DeskJet 1125C to do the test, when first pluged(USB), run the test program, it just return null string. And run again the test program, it show the correct id-string. And if pulled out and pluged again, run the program first, it will show NULL string again, and the second time it shows correct. If change the printer to Epson, the problem not exist. Is this the problem the HP printer has, or my test program? Please give me some advice, thanks in advance! Follwing is my test program: #include <usb.h> #include <stdio.h> #include <stdlib.h>
int main() { struct usb_device* dev; struct usb_bus* bus; usb_init(); usb_find_busses(); usb_find_devices(); bus = usb_get_busses(); for (; bus; bus = bus->next) { for (dev = bus->devices; dev; dev=dev->next) { if (dev->config->interface->num_altsetting == 3) //find hp printer, only hp printer has 3 altsetting in test { //begin to get device id usb_dev_handle* dev_handle; dev_handle = usb_open(dev); usb_claim_interface(dev_handle, 0); char deviceid[256] = {0}; usb_control_msg(dev_handle, 0xA1, 0, 0, 0, deviceid, 256, 50000); int i; for (i = 0; i < 256; i++) printf("%c", deviceid[i]); //first show nothing , second and later show correct id string printf("\n"); usb_release_interface(dev_handle, 0); usb_close(dev_handle); return 0; } } } return 0; } ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel