mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-02 19:29:15 +01:00
Corrected several typos in the device detection code, improved Linux detection (more efficient).
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3000 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
c1546d818f
commit
18a39c964e
@ -86,7 +86,7 @@ QStringList RawHIDConnection::availableDevices()
|
|||||||
{
|
{
|
||||||
QStringList devices;
|
QStringList devices;
|
||||||
|
|
||||||
QList<USBPortInfo> portsList = m_usbMonitor.availableDevices();
|
QList<USBPortInfo> portsList = m_usbMonitor.availableDevices(0x20a0, -1, -1);
|
||||||
// We currently list devices by their serial number
|
// We currently list devices by their serial number
|
||||||
foreach(USBPortInfo prt, portsList) {
|
foreach(USBPortInfo prt, portsList) {
|
||||||
devices.append(prt.serialNumber);
|
devices.append(prt.serialNumber);
|
||||||
|
@ -95,8 +95,8 @@ QList<USBPortInfo> USBMonitor::availableDevices()
|
|||||||
struct udev_device *dev;
|
struct udev_device *dev;
|
||||||
|
|
||||||
enumerate = udev_enumerate_new(this->context);
|
enumerate = udev_enumerate_new(this->context);
|
||||||
// udev_enumerate_add_match_subsystem(enumerate,"usb");
|
udev_enumerate_add_match_subsystem(enumerate,"usb");
|
||||||
udev_enumerate_add_match_sysattr(enumerate, "idVendor", "20a0");
|
// udev_enumerate_add_match_sysattr(enumerate, "idVendor", "20a0");
|
||||||
udev_enumerate_scan_devices(enumerate);
|
udev_enumerate_scan_devices(enumerate);
|
||||||
devices = udev_enumerate_get_list_entry(enumerate);
|
devices = udev_enumerate_get_list_entry(enumerate);
|
||||||
// Will use the 'native' udev functions to loop:
|
// Will use the 'native' udev functions to loop:
|
||||||
@ -107,24 +107,7 @@ QList<USBPortInfo> USBMonitor::availableDevices()
|
|||||||
and create a udev_device object (dev) representing it */
|
and create a udev_device object (dev) representing it */
|
||||||
path = udev_list_entry_get_name(dev_list_entry);
|
path = udev_list_entry_get_name(dev_list_entry);
|
||||||
dev = udev_device_new_from_syspath(this->context, path);
|
dev = udev_device_new_from_syspath(this->context, path);
|
||||||
|
if (QString(udev_device_get_devtype(dev)) == "usb_device")
|
||||||
/* The device pointed to by dev contains information about
|
|
||||||
the hidraw device. In order to get information about the
|
|
||||||
USB device, get the parent device with the
|
|
||||||
subsystem/devtype pair of "usb"/"usb_device". This will
|
|
||||||
be several levels up the tree, but the function will find
|
|
||||||
it.*/
|
|
||||||
/*
|
|
||||||
dev = udev_device_get_parent_with_subsystem_devtype(
|
|
||||||
dev,
|
|
||||||
"usb",
|
|
||||||
"usb_device");
|
|
||||||
if (!dev) {
|
|
||||||
printf("Unable to find parent usb device.");
|
|
||||||
return devicesList;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
devicesList.append(makePortInfo(dev));
|
devicesList.append(makePortInfo(dev));
|
||||||
udev_device_unref(dev);
|
udev_device_unref(dev);
|
||||||
}
|
}
|
||||||
@ -144,7 +127,7 @@ QList<USBPortInfo> USBMonitor::availableDevices(int vid, int pid, int bcdDevice)
|
|||||||
QList<USBPortInfo> thePortsWeWant;
|
QList<USBPortInfo> thePortsWeWant;
|
||||||
|
|
||||||
foreach (USBPortInfo port, allPorts) {
|
foreach (USBPortInfo port, allPorts) {
|
||||||
if((port.vendorID==vid || vid==-1) && (port.productID==pid || vid==-1) && (port.bcdDevice==bcdDevice || bcdDevice==-1))
|
if((port.vendorID==vid || vid==-1) && (port.productID==pid || pid==-1) && (port.bcdDevice==bcdDevice || bcdDevice==-1))
|
||||||
thePortsWeWant.append(port);
|
thePortsWeWant.append(port);
|
||||||
}
|
}
|
||||||
return thePortsWeWant;
|
return thePortsWeWant;
|
||||||
@ -183,14 +166,15 @@ USBPortInfo USBMonitor::makePortInfo(struct udev_device *dev)
|
|||||||
//////////
|
//////////
|
||||||
|
|
||||||
|
|
||||||
prtInfo.vendorID = QString(udev_device_get_sysattr_value(dev, "idVendor")).toInt();
|
bool ok;
|
||||||
prtInfo.productID = QString(udev_device_get_sysattr_value(dev, "idProduct")).toInt();
|
prtInfo.vendorID = QString(udev_device_get_sysattr_value(dev, "idVendor")).toInt(&ok, 16);
|
||||||
|
prtInfo.productID = QString(udev_device_get_sysattr_value(dev, "idProduct")).toInt(&ok, 16);
|
||||||
prtInfo.serialNumber = QString(udev_device_get_sysattr_value(dev, "serial"));
|
prtInfo.serialNumber = QString(udev_device_get_sysattr_value(dev, "serial"));
|
||||||
prtInfo.manufacturer = QString(udev_device_get_sysattr_value(dev,"manufacturer"));
|
prtInfo.manufacturer = QString(udev_device_get_sysattr_value(dev,"manufacturer"));
|
||||||
prtInfo.product = QString(udev_device_get_sysattr_value(dev,"product"));
|
prtInfo.product = QString(udev_device_get_sysattr_value(dev,"product"));
|
||||||
// prtInfo.UsagePage = QString(udev_device_get_sysattr_value(dev,""));
|
// prtInfo.UsagePage = QString(udev_device_get_sysattr_value(dev,""));
|
||||||
// prtInfo.Usage = QString(udev_device_get_sysattr_value(dev,""));
|
// prtInfo.Usage = QString(udev_device_get_sysattr_value(dev,""));
|
||||||
prtInfo.bcdDevice = QString(udev_device_get_sysattr_value(dev,"bcdDevice")).toInt();
|
prtInfo.bcdDevice = QString(udev_device_get_sysattr_value(dev,"bcdDevice")).toInt(&ok, 16);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ QList<USBPortInfo> USBMonitor::availableDevices(int vid, int pid, int bcdDevice)
|
|||||||
QList<USBPortInfo> thePortsWeWant;
|
QList<USBPortInfo> thePortsWeWant;
|
||||||
|
|
||||||
foreach (USBPortInfo port, allPorts) {
|
foreach (USBPortInfo port, allPorts) {
|
||||||
if((port.vendorID==vid || vid==-1) && (port.productID==pid || vid==-1) && (port.bcdDevice==bcdDevice || bcdDevice==-1))
|
if((port.vendorID==vid || vid==-1) && (port.productID==pid || pid==-1) && (port.bcdDevice==bcdDevice || bcdDevice==-1))
|
||||||
thePortsWeWant.append(port);
|
thePortsWeWant.append(port);
|
||||||
}
|
}
|
||||||
return thePortsWeWant;
|
return thePortsWeWant;
|
||||||
|
@ -70,7 +70,7 @@ QList<USBPortInfo> USBMonitor::availableDevices(int vid, int pid, int bcdDevice)
|
|||||||
QList<USBPortInfo> thePortsWeWant;
|
QList<USBPortInfo> thePortsWeWant;
|
||||||
|
|
||||||
foreach (USBPortInfo port, allPorts) {
|
foreach (USBPortInfo port, allPorts) {
|
||||||
if((port.vendorID==vid || vid==-1) && (port.productID==pid || vid==-1) && (port.bcdDevice==bcdDevice || bcdDevice==-1))
|
if((port.vendorID==vid || vid==-1) && (port.productID==pid || pid==-1) && (port.bcdDevice==bcdDevice || bcdDevice==-1))
|
||||||
thePortsWeWant.append(port);
|
thePortsWeWant.append(port);
|
||||||
}
|
}
|
||||||
return thePortsWeWant;
|
return thePortsWeWant;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user