If you are using version 5.2.0 or later of WinDriver, you can use
WinDriver's API to register to listen to specific Plug-and-Play and/or power
management notifications from the OS, including notifications of device
insertion/removal, and implement a relevant callback in your application to handle
such situations. When using version 6.0 and above, use
WDU_Init() to register to listen for the notifications you are
interested in. In versions 5.2.0–5.2.2, use
event_register(). Please refer to the WinDriver User's Manual for
the WinDriver version that you are using for a detailed description of the relevant
APIs.
In earlier versions of WinDriver — version 5.0.5b or below —
WinDriver did not provide specific API support for Plug-and-Play and power
management events. In these versions, WD_UsbScanDevice()
detects the devices which are connected to the computer at the time of the function
call. If another device is later connected to the computer, or a device is
disconnected, these changes will not automatically be detected.
WD_UsbScanDevice() must be called again in order to detect the
changes. However, since WinDriver USB drivers are user mode WIN32 applications,
they can get a notification of insertion/removal. Windows sends all applications a
WM_DEVICECHANGE message. Once the application receives this
message it should call WD_UsbScanDevice() to check if the device
was inserted/removed (this is only good for Windows). You should therefore be able
to implement PnP device insertion/removal support with earlier versions of WinDriver
as well, using the Win32 API. You can also send a
GET_DESCRIPTOR request to the device (using
WD_UsbTransfer() to verify if the device is connected. Please
note that in order to handle the device after it has been disconnected,
you must first call WD_UsbDeviceUnregister() to free the previous
handle to the device, then re-scan the USB bus to locate the device (using
WD_UsbDeviceScan()), get the device's configuration information
(by calling WD_UsbGetConfiguration() and re-register the device
by calling WD_UsbDeviceRegister().
.
|