【问题标题】:Unable to detect USB device无法检测到 USB 设备
【发布时间】:2013-05-08 15:36:19
【问题描述】:

这是我的代码:

#include "MyClass.h"
#include <qstring.h>
#include <qdebug.h>

   MyClass::MyClass()
   {
       QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();

       int counter=0;

       while(counter<ports.size())
       {
       QString portName = ports[counter].portName;
       QString productId= ports[counter].productID;
       QString physicalName = ports[counter].physName;
       QString vendorId = ports[counter].vendorID;
       QString friendName = ports[counter].friendName;


       string convertedPortName = portName.toLocal8Bit().constData();
       string convertedProductId = productId.toLocal8Bit().constData();
       string convertedPhysicalName = physicalName.toLocal8Bit().constData();
       string convertedVendorId = vendorId.toLocal8Bit().constData();
       string convertedFriendName = friendName.toLocal8Bit().constData();

       cout << "Port Name: " << convertedPortName << endl;
       cout << "Product ID:" << convertedProductId << endl;
       cout << "Physical Name: " << convertedPhysicalName << endl;
       cout << "Vendor Id: " << convertedVendorId << endl;
       cout << "Friend Name: " << convertedFriendName << endl;
       cout << endl;
       counter++;

       }
   }

我已经连接了“Dreamcheeky Thunder Missile Launcher”USB 玩具,但我无法获得它的供应商 ID 或产品 ID 或至少任何与之相关的信息!见下图

但是使用 USBDView 软件,我可以得到所有的细节。见下图

我的代码有什么问题?或者如果它根本不适合?

【问题讨论】:

  • QExtSerial 用于串行端口,所以我假设它列出了串行设备(一些模拟的),而不是 USB。我会尝试使用 libusb。
  • @FrankOsterfeld:我安装了它,但它搞砸了一切。玩具的软件也停止工作。无论如何,如果我开始一个新线程寻求安装帮助,你介意给我一步一步的说明吗?
  • @Artificial_Intelligence:你试过QtSerialPort吗?

标签: c++ qt usb qextserialport


【解决方案1】:

只是运行玩具的安装程序并检查它提供了什么,它没有描述任何 API 或文档来访问它作为串行端口。

如果你在他们的程序上使用了某种监控程序,你也许可以对它如何命令设备进行逆向工程。

直接与他们的 UI 交互可能更容易。使用 AHK 之类的程序或调用 SendInput() 来获取相对于其 UI 左上角的坐标,您可以控制设备的方向。

编辑:与此相关的更多链接: 因为 USB 设备没有被列为 COM#(串行端口的显示方式),并且它是一个 HID 设备,所以您需要一个可以与之通信的库。以下是一些应该可以帮助您到达那里的链接:

http://www.qtcentre.org/threads/41075-USB-HID-connect-on-QT

http://www.signal11.us/oss/hidapi/

https://github.com/iia/Qt_libusb

看起来 Robo Realm 的人已经做到了:

http://www.roborealm.com/help/DC_Missile.php

http://www.roborealm.com/help/USB_HID.php

http://www.roborealm.com/tutorial/usb_missile_launcher/slide010.php

希望对您有所帮助。

【讨论】:

  • 感谢您的回复。实际上,这个设备是可以编程的。他们有一个文档,描述了我们需要发送的信号
  • 那是用于 OIC 发射器的,但他们确认除了缺少相机外其他东西是一样的。我通过USB监控软件发现是真的
猜你喜欢
  • 1970-01-01
  • 2012-05-10
  • 1970-01-01
  • 2016-09-03
  • 2023-03-03
  • 2011-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多