PeakGen
PeakGen

Reputation: 23025

Unable to detect USB device

Here is my 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

enter image description here

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

enter image description here

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

Upvotes: 0

Views: 436

Answers (1)

phyatt
phyatt

Reputation: 19112

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.

Missile Launcher UI

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.

Upvotes: 1

Related Questions