🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages Started by Anthony Fri, 01 Jun 2007 01:53
USB Device Detection
#1901
Author: Anthony
Date: Fri, 01 Jun 2007 01:53
24 lines
1854 bytes
Hello all,

I have an interesting problem, which I think the solution may be a bit
above my knowledge level but I think is completely doable.

The question is: How do I go about programmatically initiating the USB
hardware detection sequence?

I have a competer system with an internal USB connection to a
removable device. The problem that I am having is that when I plug in
the devices I have to unplug and plug in the USB cable to initiate the
USB hardware detection routine so that the device can be accessed by
the OS. I would really like to get away from the unplug/plug step and
was thinking I should be able to do it programmatically with a small
program. I just don't know how and thought I would inquire here with
the experts.

Any suggestions that you have would be greatly appreciated, especially
code snippets since this may be more on the driver level that I have
worked with before.

Thank you all for your time,
Anthony
Re: USB Device Detection
#1902
Author: AlexB
Date: Fri, 01 Jun 2007 03:44
25 lines
1681 bytes
Anthony wrote:

> ...when I plug in
> the devices I have to unplug and plug in the USB cable to initiate the
> USB hardware detection routine so that the device can be accessed by
> the OS. I would really like to get away from the unplug/plug step and
> was thinking I should be able to do it programmatically with a small
> program.
...
> Any suggestions ...

You can use MS utility DevCon.exe.
Example: restart all devices with VID=0x0547 and PID=0x2005

devcon.exe restart "@USB\VID_0547&PID_2005\*"

This utility is very useful when something goes wrong and you have to
restart driver and start the enumeration without device unplugging.

Do not forget to wait the end of work of the utility before continue
(for example with WinExecAndWait32 by Peter Below). And some devices
(based on Cypress chip) do enumeration twice so for them it is
necessary to add an additional pause.
-- 
Alex.
Re: USB Device Detection
#1904
Author: Mike Collins
Date: Fri, 01 Jun 2007 14:01
34 lines
2265 bytes
Don't know if it will help but you can use RegisterDeviceNotification (...) 
win32 API  to register with the system, and thus be informed of such updates 
as a USB device being inserted or removed.

HTH

Mike

<Anthony> wrote in message 
news:vluu53p1td3u3tiir0rqo3fd29sicr7cdc@4ax.com...
>
> Hello all,
>
> I have an interesting problem, which I think the solution may be a bit
> above my knowledge level but I think is completely doable.
>
> The question is: How do I go about programmatically initiating the USB
> hardware detection sequence?
>
> I have a competer system with an internal USB connection to a
> removable device. The problem that I am having is that when I plug in
> the devices I have to unplug and plug in the USB cable to initiate the
> USB hardware detection routine so that the device can be accessed by
> the OS. I would really like to get away from the unplug/plug step and
> was thinking I should be able to do it programmatically with a small
> program. I just don't know how and thought I would inquire here with
> the experts.
>
> Any suggestions that you have would be greatly appreciated, especially
> code snippets since this may be more on the driver level that I have
> worked with before.
>
> Thank you all for your time,
> Anthony 
Re: USB Device Detection
#1907
Author: Anthony
Date: Fri, 01 Jun 2007 21:09
34 lines
1967 bytes
I used the follwing command:

devcon restart "@usb\root_hub20\*"

It took a little work to figure out what to restart.

Anthony

On 31 May 2007 20:44:01 -0700, "AlexB" <b.a.v@inbox.ru> wrote:

>Anthony wrote:
>
>> ...when I plug in
>> the devices I have to unplug and plug in the USB cable to initiate the
>> USB hardware detection routine so that the device can be accessed by
>> the OS. I would really like to get away from the unplug/plug step and
>> was thinking I should be able to do it programmatically with a small
>> program.
>...
>> Any suggestions ...
>
>You can use MS utility DevCon.exe.
>Example: restart all devices with VID=0x0547 and PID=0x2005
>
>devcon.exe restart "@USB\VID_0547&PID_2005\*"
>
>This utility is very useful when something goes wrong and you have to
>restart driver and start the enumeration without device unplugging.
>
>Do not forget to wait the end of work of the utility before continue
>(for example with WinExecAndWait32 by Peter Below). And some devices
>(based on Cypress chip) do enumeration twice so for them it is
>necessary to add an additional pause.
Re: USB Device Detection
#1909
Author: Maurice
Date: Sat, 02 Jun 2007 11:10
33 lines
2095 bytes
"AlexB" <b.a.v@inbox.ru> wrote in message 
news:465f9601$1@newsgroups.borland.com...
> Anthony wrote:
>
>> ...when I plug in
>> the devices I have to unplug and plug in the USB cable to initiate the
>> USB hardware detection routine so that the device can be accessed by
>> the OS. I would really like to get away from the unplug/plug step and
>> was thinking I should be able to do it programmatically with a small
>> program.
> ...
>> Any suggestions ...
>
> You can use MS utility DevCon.exe.
> Example: restart all devices with VID=0x0547 and PID=0x2005
>
> devcon.exe restart "@USB\VID_0547&PID_2005\*"
>
> This utility is very useful when something goes wrong and you have to
> restart driver and start the enumeration without device unplugging.
>
> Do not forget to wait the end of work of the utility before continue
> (for example with WinExecAndWait32 by Peter Below). And some devices
> (based on Cypress chip) do enumeration twice so for them it is
> necessary to add an additional pause.
> -- 
> Alex.

where is devcon?, I don't find it in my system (WIN XP SP2)

thanks
Maurice
Re: USB Device Detection
#1910
Author: Michel Leunen
Date: Sat, 02 Jun 2007 17:58
14 lines
1372 bytes
Maurice wrote:

> where is devcon?, I don't find it in my system (WIN XP SP2)

Did you search?
http://support.microsoft.com/kb/311272/

Michel
-- 
----------------------------------------
Michel Leunen
http://www.leunen.com/

----------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads