How to perform a hardware reset of a specific HID device?
Asked Answered
E

1

12

The aim

Perform a hardware reset of a specific USB dongle ANT, HID device, with Delphi app.


1. CM_Request_Device_Eject function attempt

I have tried to use the CM_Request_Device_Eject function and it correctly ejects my device, but on some systems does not automatically start it again.

This is the code I've used for the device eject:

str := PChar(GetDeviceID(DeviceInfoData.DevInst));
status := CM_Locate_DevNodeA(dev, str, CM_LOCATE_DEVNODE_NORMAL);
status := CM_Request_Device_EjectA(dev, nil, '', 0, 0);

Is there a way to ensure that my device will start if it does not automatically start after eject when using this function ?


2. SetupDiRestartDevices function attempt

As an alternative I've tried to use the SetupDiRestartDevices function and this one properly resets my device, but except that resets all the HID devices (such as mouse, keyboard, etc.), and this function requires administrator rights to work:

rslt1 := SetupDiRestartDevices(hDevInfo, DeviceInfoData);

How can I reset only my device with this function ?


Question

Is there a generic, recommended way to perform a hardware reset of a specific USB HID device ? Or is there a way to resolve any of the above problems ?

Enisle answered 4/11, 2013 at 13:15 Comment(2)
Have you tried using DeviceIoControl with IOCTL_HID_DEACTIVATE_DEVICE and IOCTL_HID_ACTIVATE_DEVICE it depends on the vendor of the driver, but it may be worth a tryTorrens
I don't think this would be possible to achieve per port, at best per hub maybe. Related: #404597 - superuser.com/a/132794Rule
P
1

Hard reset is not something you can do just of your own... to do a hard reset to some device, that particular device must support hard reset... ways hard reset varies from device to device. some devices have a button on it to do a hard reset. some requires a piece of code. most of the company releases a set of AT-command lists for there specific devices..

for example.. here is list of at commands released by the manufacturer for there specific device

this can help you in this case... if not keep googling.

Parsec answered 16/10, 2016 at 13:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.