Author Topic: How do I determine if Windows drivers have loaded  (Read 14907 times)

Virgil Gomes

  • Member
  • ***
  • Posts: 15
How do I determine if Windows drivers have loaded
« on: April 16, 2012, 04:56:19 pm »
Hi,

I'm new to USB and need some help. I'm using C# Example code 5.0 as my plateform using OS Win 7.

After I connect a new USB device to my PC, my program detects the device via FindTheHid(), the Windows driver then loads anywhere from 10 to 30 seconds later, the I am able to communicate to my device. I account for this in my code but find it not efficient. Here is the code:

                while (!(myDeviceDetected = FindTheHid()) && (attempts < 30))
                {
                    Debug.WriteLine("Can't find the serialized device!");
                    lstResults.Items.Add("   ....Waiting for device to re-enumerate");
                    Thread.Sleep(15000); // wait for 15 sec
                     attempts++;
                }

Is there a way to detect that the Windows Driver loaded?

Thank you,
Virgil

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How do I determine if Windows drivers have loaded
« Reply #1 on: April 16, 2012, 05:54:33 pm »
If the system has a USB keyboard or mouse, the HID drivers are loaded.

If there is a problem with installing the device, the setupapi log file might offer a clue:

http://support.microsoft.com/kb/927521

Jan

Virgil Gomes

  • Member
  • ***
  • Posts: 15
Re: How do I determine if Windows drivers have loaded
« Reply #2 on: April 17, 2012, 08:20:17 am »
Hi,

I am production testing the same device (PID and VID) with different serial numbers.  I install, test, and remove the devices, and on the installation of each of the devices, a driver is loaded every time. The devices are HID. If I start testing before the driver is done loading I will get exceptions. Is there a way to determine if the driver is done loading?

I did look at the link that was suggested and was not able to locate the setupapi.log file.

Thank you,
Virgil

Virgil Gomes

  • Member
  • ***
  • Posts: 15
Re: How do I determine if Windows drivers have loaded
« Reply #3 on: April 17, 2012, 08:21:52 am »
Hi,

I forgot to mention that they system (PC) does have a mouse and keyboard.

Thank you,
Virgil

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How do I determine if Windows drivers have loaded
« Reply #4 on: April 17, 2012, 12:21:59 pm »
You can find the setupapi log file with Windows search.

In XP:

Start > Search > For Files and Folders > Search companion > All files and folders

In "all or part of the file name", enter setupapi

In "Look in", select the main drive.

One solution is to catch the exception and restart if needed.

If the device is in Device Manager, it should be available. See the WDK for the devcon example that shows how to retrieve the same device information that Device Manager shows. 

Jan
« Last Edit: April 17, 2012, 12:37:29 pm by Jan Axelson »