Ports
June 18, 2013, 06:38:32 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Welcome to the PORTS Forum. Please post your questions, answers, and comments relating to USB and other hardware interfaces in the appropriate forums below. - Jan
Pages: 1 [2]
  Print  
Author Topic: Error writing HID device  (Read 4332 times)
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1642


WWW
« Reply #15 on: February 18, 2011, 11:21:45 am »

Run USBCV if you haven't:

http://www.usb.org/developers/tools/

Test with different host controllers as we've suggested.

Jan
Logged
Guido Koerber
Frequent Contributor
****
Posts: 71


« Reply #16 on: February 19, 2011, 02:10:45 am »

Actually to catch a race condition in your code you may need access to the system on which the error happens plus a USB analyzer.

Finding such problems by reading code is likely equivalent to rewriting the whole protocol.
Logged
Jan Andersson
Member
***
Posts: 15


« Reply #17 on: March 11, 2011, 11:01:01 am »

Typically interrupt OUT endpoints are set up in hardware to NAK after receiving data until firmware retrieves the data and resets the endpoint to ACK new data. If that is happening correctly, the polling interval isn't an issue.
Is there some kind of "maximum time" a host will wait if the device keeps NAK:ing because it's busy processing a packet? I ask because I have found out that in one case it takes some 300 ms before ACK:ing a certain packet.
Logged
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1642


WWW
« Reply #18 on: March 11, 2011, 11:39:20 am »

The USB spec defines limits for control transfers. Otherwise it's up the driver. The Windows HID driver times out control transfers after 5 secs and interrupt transfers never. A keyboard might sit idle for hours, days, weeks, before someone decides to tap a key. The host doesn't know or care whether the NAK is because the endpoint is busy or has no data.

Jan
Logged
Jan Andersson
Member
***
Posts: 15


« Reply #19 on: April 14, 2011, 03:41:48 am »

After gaining physical access to a computer having the mentioned problem I finally found what most likely seems to be the cause. It is in the USB device's firmware. I use USB interrupt in combination with USB handling in the program's main loop. It was when issuing a select endpoint command in the main loop it failed getting an command-ready-ack from the USB Serial Engine. The reason for that was that I didn't know/foresee that the USB interrupt had to be temporarily turned off during the SE access, so a USB interrupt which also accessed the SE happened while the main loop was accessing the SE... The whole USB stack is based on an example, which didn't turn off the USB interrupt in the concerned functions, and I did not think about such a possibility, especially since it work on all our computers and most of the customers too...  Embarrassed
Logged
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1642


WWW
« Reply #20 on: April 14, 2011, 09:58:29 pm »

I'm glad to hear you found the problem.

Jan
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!