Windows CE Code for causing the effect of physical disconnection of USB HID device

Hi,

I am new to Windows CE and I am working on a problem where a USB scanner is
not getting recognised when the WinCE machine is booted with the scanner
connected. However the USB scanner is working when i disconnect/reconnect
the scanner post boot up of WinCE machine.

I understand that the USB scanner is managed by a USB class driver
USBHID.dll. In an attempt to simulate the scenario of physical
disconnection and reconnection of the scanner device I wrote a small
program that unloads the USBHID driver and reloads it again. I used the
APIs ActivateDeviceEx and DeActivateDevice in this program.

When I run this program the APIs were successful and program is running
smoothly. However the scanner device is still not getting detected.

Are there any other APIs in WinCE that more effectively simulate the
physical disconnection and connection of USB HID device?

Thanks,
Seetharama Sarma Jayanthy.

On May 6, 2017, at 2:01 AM, jayanth sharma wrote:
>
> I am new to Windows CE and I am working on a problem where a USB scanner is not getting recognised when the WinCE machine is booted with the scanner connected. However the USB scanner is working when i disconnect/reconnect the scanner post boot up of WinCE machine.
>
> I understand that the USB scanner is managed by a USB class driver USBHID.dll.

Where did you read that? Scanners are not HID class, so I cannot imagine why they would involve USBHID.dll.

Isn’t there a WinCE API you can use to force the device tree to be rescanned?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> Scanners are not HID class

Perhaps OP has a barcode scanner?
– pa

Sorry I missed that. Yes. My device is a bar code scanner.

On 07-May-2017 15:01, wrote:

> Scanners are not HID class

Perhaps OP has a barcode scanner?
– pa


NTDEV is sponsored by OSR

Visit the list online at: http:>

MONTHLY seminars on crash dump analysis, WDF, Windows internals and
software drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at <
http://www.osronline.com/page.cfm?name=ListServer&gt;</http:></http:>

> Yes. My device is a bar code scanner.

Can you do some experiments?
A. Connect it to a “normal” Windows PC (Win7, 8.1 …) and test how it is detected when the PC powers on or resumes from hibernation ? B. Connect it via a hub?

– pa

We tested on big windows OS such as Windows 7 and Windows 10. It was
working fine.

There is a another Interesting thing. This is happening only with some
specific devices of the category but not all of the devices. Although this
easily points out to the device being used, the requirement is to provide a
solution that would work for every device. So I am trying to simulate the
physical disconnect and connect situation.

On 07-May-2017 15:33, wrote:

> > Yes. My device is a bar code scanner.
>
> Can you do some experiments?
> A. Connect it to a “normal” Windows PC (Win7, 8.1 …) and test how it is
> detected when the PC powers on or resumes from hibernation ? B. Connect it
> via a hub?
>
> – pa
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

I’m not familiar with the differences between the CE and desktop versions of windows but from a USB perspective it sounds like the USB host and the scanner are out of sync. As in the scanner doesn’t see VBUS go away when the system is powered off so it doesn’t renegotiate the link and so doesn’t enumerate on boot. As for how to recover the device, I would suggest resetting the USB port that the device is connected to.
Here are couple things I would try to narrow down why this is happening:

  1. If the scanner is not powered by the USB port, does cycling the power to the scanner before you boot the system solve the problem? (this would point to the scanner probably not paying attention to VBUS)
  2. Does it work if you unplug and plug the scanner back in before you boot the system? Would indicate that VBUS might be always on or something else is causing the device not to be completely reset by the power off/boot cycle.
  3. Does this happen on a cold boot? System and scanner all powered down before boot. Or just on a restart (warm boot)?
  4. Does the scanner go away after a suspend/resume? (Suspend/Resume should take the USB port into and out of suspend but keep VBUS available)
  5. Does scanning for hardware changes from device manage cause the scanner to appear? If so you can look at the source code for devcon.exe which is available in the WDK. It can be used to cause a rescan and you could use the code from there in your application.
  6. Does disabling then enabling the host or hub the scanner is connected to in device manager cause the scanner to appear? For USB hubs/host this usually causes port power cycle and/or port resets on the ports.
  7. This one is much less likely and i’m not sure how applicable it is to CE but I’ve been bitten before by it. I have seen cases where the BIOS/UEFI enumerate a device during boot and then device gets left in a weird state so that when windows comes around to look for devices it doesn’t respond. This mostly happens on hibernate/restore but at least with Win 10 the default(fast) shutdown is really hibernate.

Hope some of that helps.
Eric