From: Xiaofan C. <xia...@gm...> - 2012-04-07 01:12:08
|
Please reply to the list instead of replying to me. Thanks. On Thu, Apr 5, 2012 at 9:34 AM, Quân Phạm Minh <qua...@gm...> wrote: > please view my source code: > > libusb_context *ctx = NULL; > int r; > > r = libusb_init(&ctx); > libusb_device **devs; > ssize_t k = libusb_get_device_list(ctx, &devs); > qDebug() <<"number of device:" <<k; > qDebug() <<""; > > libusb_device_descriptor desc; > for(ssize_t i = 0; i < k; i++){ > libusb_device_handle *handler; > int er = libusb_open(devs[i], &handler); > switch(er){ > case 0: > qDebug() <<"device opened"; > break; > case LIBUSB_ERROR_NO_MEM: > qDebug() <<"memory allocation failure"; > break; > case LIBUSB_ERROR_ACCESS: > qDebug() <<"the user has insufficient permissions"; > break; > case LIBUSB_ERROR_NO_DEVICE: > qDebug() <<"the device has been disconnected "; > break; > case LIBUSB_ERROR_BUSY: > qDebug() <<"resource busy"; > break; > case LIBUSB_ERROR_INTERRUPTED: > qDebug() <<"system call interrupted"; > break; > case LIBUSB_ERROR_INVALID_PARAM: > qDebug() <<"invalid parameter"; > break; > case LIBUSB_ERROR_IO: > qDebug() <<"input/output error"; > break; > case LIBUSB_ERROR_NOT_FOUND: > qDebug() <<"entity not found"; > break; > case LIBUSB_ERROR_NOT_SUPPORTED: > qDebug() <<"operation not supported or unimplemented on > platform"; > break; > case LIBUSB_ERROR_OVERFLOW: > qDebug() <<"overflow error"; > break; > case LIBUSB_ERROR_PIPE: > qDebug() <<"pipe error"; > break; > case LIBUSB_ERROR_TIMEOUT: > qDebug() <<"timeout error"; > break; > case LIBUSB_ERROR_OTHER: > qDebug() <<"other error"; > break; > } > } > > libusb_free_device_list(devs, 0); > libusb_exit(ctx); > Looks okay, but I am not a programmer myself. -- Xiaofan |