Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 717
  • Last Modified:

How do I open, close, and then reopen a device driver?

I have WinUSB installed as the driver for a USB device and everything seems to work fine the first time I access the device, I can read and write to the device. Once I close the device handles (bResult=WinUsb_Free(myDevInfo.winUsbHandle); and bResult=CloseHandle(myDevInfo.deviceHandle);), run my open routine, which worked the first time, I can not read from the device any more. bResult in both of the above statements returns TRUE, so the resources for WinUSB should have been released. Am I missing something, why can I not open the device, close the device and then open it again? I am writing the code in VC++ 6.0.
0
Eric_Braun
Asked:
Eric_Braun
1 Solution
 
jkrCommented:
Are you calling 'WinUsb_Initialize()' (http://msdn.microsoft.com/en-us/library/aa476455.aspx) again after reopening the device?
0
 
trinitrotolueneDirector - Software EngineeringCommented:
you need to pass the device interface to the initialize routine...so each time an enumeration has to be done so that you get the list of device interfaces.

Are you doing this in your intialize routine?
0
 
Eric_BraunAuthor Commented:
Sorry for not responding to any of these comments. Everytime I went to view the comments all I would get was a blank screen, think I had a bad cookie or something. Anyways that aside, I have solved this issue, worked around, all though I still am not sure why I had the issue to start with. Yes, I do 'WinUsb_Initialize()' after reopening the device and I do set and read the device interfaces. What I had to do to get this to work was after running WinUsb setup routines, loading the device firmware,  I had to issue a WinUsb_ResetPipe on the IN and OUT pipes. This takes the pipes out of any stall that may have happened, which is what seems to be happening for some reason when the device is reopened, but not the first time it is opened.
Eric
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now