Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform a hardware reset of a specific HID device?

Tags:

winapi

delphi

hid

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 ?

like image 233
Mohammad Avatar asked Nov 04 '13 13:11

Mohammad


Video Answer


1 Answers

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.

like image 99
sanjeev Avatar answered Sep 17 '22 17:09

sanjeev