PORTS Forum
Ports and Interfaces => USB => Topic started by: Virgil Gomes 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
-
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
-
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
-
Hi,
I forgot to mention that they system (PC) does have a mouse and keyboard.
Thank you,
Virgil
-
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