C++ 无法检测USB设备
这是我的密码:C++ 无法检测USB设备,c++,qt,usb,qextserialport,C++,Qt,Usb,Qextserialport,这是我的密码: #include "MyClass.h" #include <qstring.h> #include <qdebug.h> MyClass::MyClass() { QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); int counter=0; while(counter<ports.size())
#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++;
}
}
#包括“MyClass.h”
#包括
#包括
MyClass::MyClass()
{
QList ports=QextSerialEnumerator::getPorts();
int计数器=0;
虽然(counter只是运行玩具的安装程序并检查它的结果,但它没有描述任何API或文档来将其作为串行端口访问
如果你在他们的程序上使用了某种监控程序,你也许可以对它如何控制设备进行逆向工程
直接与用户界面进行交互可能更容易。使用类似AHK的程序或调用SendInput()来相对于用户界面左上角的坐标,您可以命令设备的方向
编辑:更多与此相关的链接:
由于USB设备没有列为COM#(串行端口的显示方式),而且它是一个HID设备,因此您需要一个可以与之通信的库。以下是一些链接,可以帮助您实现这一点:
看起来机器人王国的人已经做到了:
希望对您有所帮助。QExtSerial用于串行端口,因此我假设它列出了串行设备(一些模拟设备),不是USB。我会试试libusb。@Frankosterfield:我安装了它,它把一切都弄糟了。玩具的软件也停止了工作。不管怎样,如果我启动一个新线程寻求安装帮助,你介意给我一步一步的说明吗?@Artificial_Intelligence:你试过QtSerialPort吗?谢谢你的回答。实际上,这个设备可以编程他们有一份文件描述了我们需要为伊斯兰会议组织发射装置发送的信号,但他们确认除了丢失的摄像机外,其他东西都是一样的。我通过USB监控软件找到了这是真的