如何从我的应用程序调用SetPortFeature? [英] How to call SetPortFeature from my application ?

查看:759
本文介绍了如何从我的应用程序调用SetPortFeature?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调用usb函数Set_Port Feature(PORT RESET),以便从usb集线器中重置端口.

我对司机几乎一无所知...所以我什至都不知道在哪里寻找!

我知道可以将命令Set_Port Feature(PORT RESET)发送到集线器,这就是我要使集线器重置端口的原因.

I want to call usb function Set_Port Feature( PORT RESET ) so that I reset a port from the usb hub.

I do not know almost nothing about drivers ... So I do not even know where to look for!

I know that it is possible to send the command Set_Port Feature( PORT RESET ) to a hub and that is what I want to make the hub reset a port.

Any help?

推荐答案

SetPortFeature (PORT_RESET)发送到集线器只会告诉它执行USB重置.

USB供电与之分开,由ClearPortFeature (PORT_POWER)SetPortFeature (PORT_POWER)控制(对于支持每端口电源控制的集线器).
Sending SetPortFeature (PORT_RESET) to a hub will only tell it to perform a USB reset.

The supply of power over USB is separate to that, and is controlled by ClearPortFeature (PORT_POWER) and SetPortFeature (PORT_POWER) (for hubs that support per-port power control).


DevCon [ WDK [^ ] 是一个命令行实用程序,显示了如何使用SetupAPI和CfgMgr32 API函数启用,禁用,重新启动,更新,删除和查询设备.

从此处下载 DevCon :

devcon.exe [ ^ ]

在命令行中学习使用 DevCom :

devcon help


查找所有USB设备的硬件ID:

devcon find "USB\*"


重新启动所需的HUB或任何其他设备:

devcon restart "USB\ROOT_HUB20\5&3849BCE7&0"


如果超出了USB端口的电源限制,请使用

devcon rescan


重置它,或通过C#控制台应用程序执行所有操作:

The DevCon[^] example in the WDK[^] is a command-line utility that shows how to enable, disable, restart, update, remove and query devices using the SetupAPI and CfgMgr32 API functions.

Download DevCon from here:

devcon.exe[^]

Learn using DevCom from the command-line:

devcon help


Find hardware IDs for all USB devices:

devcon find "USB\*"


Restart your desired HUB or any other device:

devcon restart "USB\ROOT_HUB20\5&3849BCE7&0"


If power limits on your USB port have been exceeded use

devcon rescan


to reset it, or do something of everything from your C# console application:

using System;
using System.Diagnostics;

namespace Test
{
    class Program
    {
        public static void Main(string[] args)
        {
            var p = new Process();
            p.StartInfo = new ProcessStartInfo( @"devcon.exe", @"find USB\*" );
            p.StartInfo.UseShellExecute = false;
            p.Start();
            p.WaitForExit();

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}



希望这会有所帮助!


Tefik Becirovic



Hope this helps!


Tefik Becirovic


感谢Tefik,但这并没有真正的帮助!

我真正需要的是关闭每个端口的5V USB线-USB端口RESET!
而且您的答案没有做到.它可以像设备管理器扫描硬件"一样重新扫描USB.


我有一个自己制作的PCB板,在5V线上有一个LED,并且一直亮着. USB连接也没有重置(我已经测量过)

我进行了一些搜索,并且开始接受,唯一的方法是制作一个USB HUB特定的驱动程序!

令人遗憾的是,Microsoft驱动程序是USB的一部分,因此没有此功能.对于许多应用程序而言,能够在无需人工干预的情况下重置端口将非常有用.
Thanks Tefik but it does not really help!

What I really need is to power off the 5V USB line for each port - USB port RESET!
And your answer does not do it. It makes USB rescan like "device manager scan hardware".


I have a PCB board made by me that has a LED at the 5V line and is always ON. Also the USB connection is not reseted (I have measured it)

I have made some search and I am beginning to accept that the only way is to make a USB HUB specific driver!

It is shame that Microsoft driver does not have this function available since it is part of USB. It would be great for many applications to be able to reset the port without physicall human intervention.


这篇关于如何从我的应用程序调用SetPortFeature?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆