对 USB 传输电缆进行编程/与 USB 设备驱动程序通信

发布于 2024-07-14 02:25:12 字数 627 浏览 10 评论 0 原文

如何从 Windows 以编程方式访问 USB 传输电缆(例如 Belkin 的 Easy Transfer Cable)?

我熟悉 libusb-win32,但据我所知,将其与较新的设备一起使用与Windows Vista 似乎不太一样。

我知道 Windows Easy Transfer 可以做到这一点。 如何编写与 Windows Easy Transfer 功能相同的代码?

如果没有关于如何执行此操作的固定文档,我愿意进行一些挖掘,但我不知道从哪里开始。 如何观察 Windows Easy Transfer 正在执行的操作以了解其工作原理? 我发现 Windows 甚至在设备管理器中为传输电缆提供了自己的类别“传输电缆设备”。 我如何与这些驱动程序之一进行低级通信?

How do I programmatically access a USB transfer cable (such as Belkin's Easy Transfer Cable) from Windows?

I'm familiar with libusb-win32, but from what I can tell, using that with newer devices and with Windows Vista seems iffy.

I know that Windows Easy Transfer can do this. How do I write code that does the same thing as Windows Easy Transfer?

If there is no canned documentation on how to do this, I'm willing to do some digging, but I don't know where to start. How do I watch what Windows Easy Transfer is doing to find out how it does it? I see that Windows even gives transfer cables their own category in the Device Manager, "Transfer Cable Devices." How do I do low-level communication with one of these these drivers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

叶落知秋 2024-07-21 02:25:12

我发现 Microsoft 现在提供 WinUSB 来进行简单的用户模式通信USB 设备。 (必须首先为该设备安装 WinUSB 设备驱动程序;这有点类似于 libusb-win32 设备驱动程序。)WinUSB 可在 XP(SP2 及更高版本)和 Vista 上运行。

Easy Transfer Cable 使用 WinUSB 作为其设备驱动程序,因此我能够按照 Microsoft WinUSB howto 文档。

I found out that Microsoft now offers WinUSB for simple user-mode communication with USB devices. (A WinUSB device driver must first be installed for the device; this is somewhat similar to a libusb-win32 device driver.) WinUSB works on XP (SP2 and above) and Vista.

The Easy Transfer Cable uses WinUSB for its device driver, so I was able to communicate with it by following the example code in Microsoft's WinUSB howto document.

在你怀里撒娇 2024-07-21 02:25:12

您将需要使用低级 win32 API 来执行此操作。
微软在这里有一些关于访问人机接口设备的很好的例子。 传输电缆不像鼠标或键盘那样明确是 HID,但它符合 HID 规范。

例如,要获取 USB 设备的名称,您可以调用

HidD_GetProductString(...)

http:// msdn.microsoft.com/en-us/library/ms790920.aspx

还有更多内容,您绝对应该看一下适用于从 2000 到 Vista 的所有 Windows 版本的示例 c 应用程序。

http://msdn.microsoft.com/en-us/library/dd163258。 祝你

好运!

You will need to use the low level win32 API to do this.
Microsoft has some nice examples here on accessing a Human Interface Device. The transfer cable isn't explicitly an HID like a mouse or keyboard, but it conforms to the HID spec.

For example, to get the name of the USB device you would call

HidD_GetProductString(...)

http://msdn.microsoft.com/en-us/library/ms790920.aspx

There is lots more there, you should definitely take a look at the sample c app that works for all versions of windows from 2000 to Vista.

http://msdn.microsoft.com/en-us/library/dd163258.aspx

Good Luck!

晨与橙与城 2024-07-21 02:25:12

您需要有一根 USB 数据传输线(也称为 USB 数据连接线)
支持API或SDK,则使用如下代码:

void CU2uDlg::OnOK() 
{
BYTE        buf[65530];
LPU2URET    pU2uRet;
BOOL        bRet;
int         ret;
CString     msgstr;

ret = u2u_open();
if (ret == -1){
    AfxMessageBox("Open U2U device Success.");
}else{
    msgstr.Format("Open U2U device fail,return:%d", ret);
    AfxMessageBox(msgstr);
    return;
}

//send data
bRet = u2u_SendData(buf, 65530, ret);
if(!bRet)
{
    msgstr.Format("Send data error,return:%d", ret);
    AfxMessageBox(msgstr);
    return;
}

//receive data
while (1){
    bRet = u2u_RecvData(recvData, dataLen, ret);
    if( !bRet )
    {
        msgstr.Format("Receive data error,return:%d", ret);
        AfxMessageBox(msgstr);
        u2u_close();
        return;
    }else{
        break;
    }
}
u2u_close();


}

参见:
参考1参考2

You need to have an USB data transfer cable (also called USB data link cable) which
support API or SDK, then use the following code:

void CU2uDlg::OnOK() 
{
BYTE        buf[65530];
LPU2URET    pU2uRet;
BOOL        bRet;
int         ret;
CString     msgstr;

ret = u2u_open();
if (ret == -1){
    AfxMessageBox("Open U2U device Success.");
}else{
    msgstr.Format("Open U2U device fail,return:%d", ret);
    AfxMessageBox(msgstr);
    return;
}

//send data
bRet = u2u_SendData(buf, 65530, ret);
if(!bRet)
{
    msgstr.Format("Send data error,return:%d", ret);
    AfxMessageBox(msgstr);
    return;
}

//receive data
while (1){
    bRet = u2u_RecvData(recvData, dataLen, ret);
    if( !bRet )
    {
        msgstr.Format("Receive data error,return:%d", ret);
        AfxMessageBox(msgstr);
        u2u_close();
        return;
    }else{
        break;
    }
}
u2u_close();


}

See:
Reference1, Reference2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文