Re: USB unplug notification

Tech-Archive recommends: Fix windows errors by optimizing your registry



More detail~

The reason why you can receive notification from OS is driver info OS the
changes with CeEventHasOccurred( ) API.

If you look at driver.
You will find that the CeEventHasOccurred( ) has been placed somewhere in
USB driver plug-in detection routine. And somewhere CLOSE() in serial driver
since there is no plug-in detection inside serial driver.

That's OS will not acknowledge the cable change if driver do not info.
And driver will not acknowledge the cable change if hardware do not info.

Unfortunately, there seems to be NO hardware cable detection in COM port by
default.

SP


"BrownB" <cristian.brunelli@xxxxxxxxxxx>
???????:1b7ffaa4-6290-4408-b48f-6cf2ed7704f7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 12 Mar, 17:12, superclass <supercl...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
I depends how do process plug events. I've found that following code will
not work on Windows CE:
// read everything from message queue
while (PeekMessage(&msg,hWnd,0,0,PM_REMOVE)) {
switch (msg.message) {
// observate WM_DEVICECHANGE event - must come on USB plug in
or
plug out
// WARNING: under Windows CE message will not appear here!
see
windows procedure
case WM_DEVICECHANGE:
printf ("WM_DEVICECHANGE:%d\n",msg.wParam);
}
// do usual message processing
TranslateMessage(&msg);
DispatchMessage(&msg);
}

You must check for event in your Window Procedure:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_DEVICECHANGE:
// in case of Windows CE windows callback function is called
directly
and
// this message only comes here, but not seen by PeekMessage()
below!
printf ("WM_DEVICECHANGE:%d\n",wParam);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;

}

The reasons is that somehow some events are not placed in message queue,
but
window procedure is called directly.

Strange Microsoft logic....

"BrownB" wrote:
Hello, I'm trying to use a USB/Serial adapter in my program, detecting
when it becomes available and when it gets unplugged. At the moment I
can always get the USB notification when the device is plugged in. But
if I open the COM port, the unplugging notification is not received,
nut is somehow placed in a system queue: I say this because I receive
that notification only when I CLOSE the serial port.

Is there a way to receive the unplug notification when the device is
in use? does this depend only from the driver?

WM_DEVICECHANGE is not defined ( more precisely, is #undefined ) for
the WindowsCE 5.0 SDK. I only found that I can receive the USB
notifications only closing the COM port, and then reopening to use it
if the device is not detached. But this leads to lost data, if data is
arriving while closing the port.

I don't know how I could continue to receive these notifications while
the device is in use....note also that the adaptor should be generic
for my application, so I don't want to work on a too low level.
Thank you a lot anyway^__^


.



Relevant Pages

  • RE: xp pro sharing printer
    ... How to troubleshoot network printing problems in Windows XP ... SMB-connected print server ... Incompatible print driver ... and then redirect the port to the network server. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: USB device detection via query registry information
    ... specific parts of a driver. ... it correctly enforces exclusivity to the port ... for Windows being crash-prone? ... serenum opens the port, detects the device, ...
    (microsoft.public.development.device.drivers)
  • Re: USB device detection via query registry information
    ... it correctly enforces exclusivity to the port ... WHQL is realistically not going to be able to catch all bugs before shipment, so maybe the answer is for WHQL signing to require a commitment from the driver developer to participate in the BSOD crash dump program and issue timely bug fixes. ... Yes these things would not come free, but is it important to Microsoft to shed the reputation for Windows being crash-prone? ... serenum opens the port, detects the device, ...
    (microsoft.public.development.device.drivers)
  • Re: Adding New Drivers to Currently Installed WinCe 5.0 Image
    ... but the second model has Windows Mobile 5.0 + GSM. ... To add the modem driver I have tried that way before but it didn't work. ... And finally, about the barcode problem, you’re right. ... on that port. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Display of print properties windows
    ... Not sure on the software uninstall. ... probably want the extra features in the HP driver but being able to select ... Windows Printing Team ... If the printer is attached to LPT1 select that port. ...
    (microsoft.public.windowsxp.print_fax)