Solved

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

Posted on 2009-07-16
5
711 Views
Last Modified: 2013-12-14
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
Comment
Question by:Eric_Braun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 24886284
Are you calling 'WinUsb_Initialize()' (http://msdn.microsoft.com/en-us/library/aa476455.aspx) again after reopening the device?
0
 
LVL 12

Expert Comment

by:trinitrotoluene
ID: 24887845
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
 

Accepted Solution

by:
Eric_Braun earned 0 total points
ID: 24984525
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

Featured Post

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question