Hi,I just trying to do a simple bulk read, and always got a TIMEOUT, would any one please tell me what I did wrong here?
Here is my code: Thanks in advance. John I also attached the USBTrace different between Windows API call vs LibsUSB Call, please remove the .remove from the WinAPIvsLibUSBCall Trace Difference.html.remove<https://mail.google.com/mail/?ui=2&ik=699f5912f2&view=att&th=1396599ed6d4a356&attid=0.1&disp=safe&realattid=f_h6cv4bg90&zw> void LIBUSB_CALL LibUSBDevice::ReadCallback(struct libusb_transfer *transfer) { CallBackData* data =(CallBackData*)transfer->user_data; data->ByteTransfered=transfer->actual_length; data->ErrorCode==transfer->status; data->ExitTransfer=true; } ErrNo LibUSBDevice::BulkRead( const ULONG c_ulPipeNum, // IN const uint c_uiLength, // IN DWORD* bytesRead, // IN uint* pbBuffer, // IN HANDLE cancelEvent) { const ULONG endpoint=0x80+c_ulPipeNum*2; CallBackData* userdata=new CallBackData(); userdata->ExitTransfer=false; int err =0; libusb_transfer* transfer =libusb_alloc_transfer(0); if (!transfer) { err=-ENOMEM; return NULL; } unsigned char* buffer=new unsigned char[c_uiLength]; libusb_fill_bulk_transfer (transfer,m_handle,endpoint,buffer, c_uiLength,LibUSBDevice:: ReadCallback ,userdata,ITP_TRANSFER_TIMEOUT); if (!err) { err = libusb_claim_interface(this->m_handle, 0); int cnt=0; err=libusb_submit_transfer(transfer); while (!userdata->ExitTransfer) { struct timeval tv = { 1, 0 }; err = libusb_handle_events_timeout(NULL, &tv); cout << ++cnt << " call libusb_handle_events_timeout" << std::endl; if (err<0) break; } } if (err < 0) { const char* errmsg=libusb_error_name(err); std::cerr << "Error!" << err << std::endl; libusb_cancel_transfer(transfer); libusb_handle_events(NULL) ; } for (int i=0;i<c_uiLength;i++) { pbBuffer[i]=static_cast<unsigned int>(buffer[i]); } libusb_release_interface(m_handle,0); return err; } Debug Trace. [30.617751] [00001f2c] libusbx: debug [libusb_claim_interface] interface 0 [30.617751] [00001f2c] libusbx: debug [winusb_claim_interface] claimed interface 0 [30.618751] [00001f2c] libusbx: debug [libusb_get_config_descriptor] index 0 [30.618751] [00001f2c] libusbx: debug [windows_assign_endpoints] (re)assigned endpoint 01 to interface 0 [30.618751] [00001f2c] libusbx: debug [windows_assign_endpoints] (re)assigned endpoint 02 to interface 0 [30.619751] [00001f2c] libusbx: debug [windows_assign_endpoints] (re)assigned endpoint 04 to interface 0 [30.619751] [00001f2c] libusbx: debug [windows_assign_endpoints] (re)assigned endpoint 86 to interface 0 [30.619751] [00001f2c] libusbx: debug [windows_assign_endpoints] (re)assigned endpoint 88 to interface 0 [30.620751] [00001f2c] libusbx: debug [winusb_submit_bulk_transfer] matched endpoint 88 with interface 0 [30.620751] [00001f2c] libusbx: debug [winusb_submit_bulk_transfer] reading 30 bytes [30.620751] [00001f2c] libusbx: debug [usbi_add_pollfd] add fd 5 events 1 [30.621751] [00001f2c] libusbx: debug [libusb_get_next_timeout] next timeout in 2.999092s [30.621751] [00001f2c] libusbx: debug [libusb_handle_events_timeout_completed] doing our own event handling [30.621751] [00001f2c] libusbx: debug [handle_events] poll() 2 fds with timeout in 1000ms [31.621808] [00001f2c] libusbx: debug [handle_events] poll() returned 0 1 call libusb_handle_events_timeout [31.626809] [00001f2c] libusbx: debug [libusb_get_next_timeout] next timeout in 1.993924s [31.627809] [00001f2c] libusbx: debug [libusb_handle_events_timeout_completed] doing our own event handling [31.628809] [00001f2c] libusbx: debug [handle_events] poll() 2 fds with timeout in 1000ms [40.662325] [00001f2c] libusbx: debug [handle_events] poll() returned 0 [40.662325] [00001f2c] libusbx: debug [libusb_cancel_transfer] [40.662325] [00001f2c] libusbx: debug [winusb_abort_transfers] will use interface 0 2 call libusb_handle_events_timeout [40.668326] [00001f2c] libusbx: debug [libusb_get_next_timeout] no URB with timeout or all handled by OS; no timeout! [40.668326] [00001f2c] libusbx: debug [libusb_handle_events_timeout_completed] doing our own event handling [40.669326] [00001f2c] libusbx: debug [handle_events] poll() 2 fds with timeout in 1000ms [40.669326] [00001f2c] libusbx: debug [handle_events] poll() returned 1 [40.670326] [00001f2c] libusbx: debug [windows_handle_events] checking fd 3 with revents = 0000 [40.670326] [00001f2c] libusbx: debug [windows_handle_events] checking fd 5 with revents = 0001 [40.671326] [00001f2c] libusbx: debug [usbi_remove_pollfd] remove fd 5 [40.671326] [00001f2c] libusbx: debug [windows_transfer_callback] handling I/O completion with errcode 995 [40.671326] [00001f2c] libusbx: debug [windows_transfer_callback] detected timeout [40.672326] [00001f2c] libusbx: debug [usbi_handle_transfer_completion] transfer 0032C830 has callback 012A5DFC 3 call libusb_handle_events_timeout [44.476544] [00001f2c] libusbx: debug [libusb_release_interface] interface 0
WinAPIvsLibUSBCall Trace Difference.html.remove
Description: Binary data
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel