[英]Unable to detect USB device
请看下面的代码
#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++;
}
}
我已经连接了“梦幻般的雷声发射器” USB玩具,但是我无法获得它的供应商ID或产品ID或与之相关的任何东西! 见下图
但是使用USBDView软件,我可以获得所有详细信息。 见下图
我的代码有什么关系? 还是根本不适合? 请帮忙!
只是运行玩具的安装程序并检查其附带的内容,它没有描述任何用于通过串行端口访问它的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
希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.