Author Topic: Device reset  (Read 20191 times)

ChicagoMike

  • Member
  • ***
  • Posts: 6
Device reset
« on: August 10, 2010, 12:00:31 pm »
Hi,

I'm working on a WinXP C++ application that I use to communicate with a full speed device that implements HID DC. I've been able to enumerate and communicate with the device beautifully.

My question is this: How can I reset the port using only the Windows API? I tried using DeviceIoControl() with both IOCTL_INTERNAL_USB_CYCLE_PORT and IOCTL_INTERNAL_USB_RESET_PORT, but neither seems to work reliably. The LVR developer's guide doesn't seem to address this (unless I'm missing something).

Any suggestions?

Thanks in advance for your kind assistance.

Mike
 

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Device reset
« Reply #1 on: August 10, 2010, 12:27:09 pm »
Why does your host application need to reset the port?

Jan

ChicagoMike

  • Member
  • ***
  • Posts: 6
Re: Device reset
« Reply #2 on: August 10, 2010, 12:45:45 pm »
Both the device firmware and the host application are legacy products with thousands of copies in the field. After all this time, a bug has emerged on the device end. Resetting the port from the application end is a possible workaround. This might seem kludgy to you (it certainly does to me), but a point release of the host application via FTP is much less painful than having to patch embedded code.

Which, since I'm getting the feeling that you don't want to answer my original question, I'll ask another: A different workaround would be to send a Set Configuration request to the device, but when I try to do that with HidD_SetConfiguration(), I get the error 'Incorrect function', and I can't figure out why.

In both cases I'm using the device handle obtained from the CreateFile() call during the device discovery process.

Any advice?

Thanks,

Mike

ChicagoMike

  • Member
  • ***
  • Posts: 6
Re: Device reset
« Reply #3 on: August 10, 2010, 12:47:08 pm »
P.S.

HidD_GetConfiguration() fails in exactly the same manner.

Thanks again,

Mike

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Device reset
« Reply #4 on: August 10, 2010, 02:08:26 pm »
The DevCon example in the WDK shows how to enable, disable, restart, update, remove and query devices. I don't know if any of those would solve your problem.

HidD_GetConfiguration and HidD_SetConfiguration are reserved for internal use:

http://msdn.microsoft.com/en-us/library/ff543370%28VS.85%29.aspx

Sending a Set_Configuration request would require a custom driver. I believe IOCTL_INTERNAL_USB_RESET_PORT must be called by a low-level driver as well.

Jan

ChicagoMike

  • Member
  • ***
  • Posts: 6
Re: Device reset
« Reply #5 on: August 10, 2010, 04:22:48 pm »
Thank you, Jan.

I really appreciate your quick response.

Mike

Chicago Bob

  • Member
  • ***
  • Posts: 1
Re: Device reset
« Reply #6 on: April 11, 2011, 03:56:31 pm »
Hi,
I work with ChicagoMike, and I know he was successful in getting the USB port to reset by heeding Jan's suggestion to follow the DevCon code example.  The two functions that really did the trick for him were SetupDiSetclassInstallParams() and SetupDiCallClassInstaller() using DIF_PROPERTYCHANGE.  This scheme works fine on Windows XP 32-bit, but now we're getting complaints that the USB fails reset on Windows 7 64-bit.  I'm involved now because I've been asked to fix it.
My debugging shows that SetupDiCallClassInstaller() returns FALSE on the 64-bit OS.  Googling this turns up several forums with developers reporting the same problem.  Most threads end right there, but I did find a little more info on the microsoft social.msdn general development issues forum.  Several more people report this problem and one says that a SetupDiCallClassInstaller() call from a 32-bit application won't work on a 64-bit OS.  (I haven't been able to confirm this in Microsoft documentation.)  Does anyone know if this statement is true?  I'm hoping there is a better fix than porting our code to a 64-bit application.  Any thoughts would be appreciated.

Thank you, Bob

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Device reset
« Reply #7 on: April 12, 2011, 10:45:07 am »
It sounds like you've researched it pretty well. Maybe someone will pipe up here, but the MS forums are probably a better bet.

Chicago Bob/Chicago Mike - I had an uncle Bob and an uncle Mike from Chicago.

Jan