Tech Support > Microsoft Windows > Drivers > USB detection - how do I tell when Windows is done??
USB detection - how do I tell when Windows is done??
Posted by Daniel Miller on February 24th, 2005


I have a 12-slot USB tester here, running WinXP Pro SP1. I'm using the
Host enumeration method documented in UsbView to determine what devices
are present after powering up the machine. I'm having a problem, though.
Windows is busy trying to detect these devices at the same time as I am,
and it takes a Looooong time to finish the job, especially when it's
never seen any of the specific devices before (i.e., 30-50 seconds to
finish processing 12 devices, if they all have new serial numbers).

The problem that I've found is this; if I put a long delay in the code,
and make sure Windows is done before I start enumerating devices,
everything works fine. However, if I start off calling the enumeration
functions before Windows is done, various problems occur; either Windows
does not ultimately register some of the devices properly, or they appear
to work but don't get normal data transfer rates, or various other
anomalies.

Details: My enumeration process is: call the UsbView enumeration
functions (which are DeviceIOControl calls with various IOCTL_USB_
variants). If any of them fail, stop and wait five seconds, then try
again. BTW, this is all being done from a user application, not a device
driver.

Once this works successfully, I open the devices using CreateFile, and do
some other data collection. However, in this case, I'm not going that
far. I'm finding that just calling these enumeration functions while
Windows is still busy working on the devices, is suffient to cause
problems later, as I described previously.

So, my questions are these:

1. Is there some way I can programmatically determine when Windows is
done doing its work, without me accessing the devices themselves, so I
can tell when its okay for me to proceed??

2. Is there some way to speed up Windows' enumeration processes?? Having
to wait 30-50 seconds each time a new bank of parts is inserted, is not
going to be a good thing in a production environment.

I would be *very* grateful for assistance with these problems.

Dan Miller

Posted by Marc Reinig on February 24th, 2005


Windows is not meant to be a production tester. So the enumeration takes as
long as it takes.

As far as knowing when Windows is through enumerating each device, monitor
WM_DEVICECHANGE and look DBT_DEVICEARRIVAL .

Marco
________________________
Marc Reinig
UCO/Lick Observatory
Laboratory for Adaptive Optics

"Daniel Miller" <gorlash@community.nospam> wrote in message
news:Xns96075F6E2C375dancarddupercom@207.46.248.16 ...


Posted by Daniel Miller on February 24th, 2005


Oh, MY!! That works very nicely indeed!!! Thank you very much...
I didn't know anything about those messages...

Dan


"Marc Reinig" <Marco@newsgroups.nospam> wrote in
news:ekORBupGFHA.3156@TK2MSFTNGP10.phx.gbl:


Posted by Robert Marquardt on February 25th, 2005


Marc Reinig wrote:

This does not help if you use a service. Windows starts the service
before enumeraton is completed and does not always send WM_DEVICECHANGE
then.

Posted by Maxim S. Shatskih on February 25th, 2005


This was always working for me. Note that the filenames sent to service
notifications are always Unicode (WCHAR) and not TCHAR.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Posted by Robert Marquardt on February 26th, 2005


Maxim S. Shatskih wrote:

That is no problem with my app because i then enumerate the devices to
find the new HID device. Maybe the Windows bug is there.


Similar Posts