简体   繁体   中英

Unable to detect USB device

Please have a look at the following code

#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++;

       }
   }

I have connected "Dreamcheeky Thunder Missile Launcher" USB toy, but I am unable to get it's Vendor ID or product ID or atleast anything related to it! See the following image

在此处输入图片说明

But using USBDView software, I can get all the details. See the following image

在此处输入图片说明

What is matter with My code? Or if it is simply not suitable? Please help!

Just running the installer for the toy and checking what it comes up with, it doesn't describe any API or documentation for accessing it as a serial port.

If you used some sort of monitoring program on their program you could maybe reverse engineer how it commands the device.

It may be easier just to interface with their UI directly. Using a program like AHK or calling SendInput() to coordinates relative to the upper left corner of their UI, you could command the directions of the device.

导弹发射器界面

EDIT: More links related to this: Because the USB device doesn't get listed as a COM# (how serial port shows up), and it is a HID device, you need a library that can talk to that. Here are some links that should help you get there:

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

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

https://github.com/iia/Qt_libusb

It also looks like the guys at Robo Realm have done it already:

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

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM