Skip to content

Commit

Permalink
use osvr usb serial functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophHaag committed Aug 31, 2016
1 parent f4f0779 commit a2303e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions OSVR-CPI.pro
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ HEADERS += mainwindow.h \
lib_json/json_tool.h \
version.h

LIBS += -losvrUSBSerial

FORMS += mainwindow.ui

DISTFILES += \
Expand Down
20 changes: 18 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include <QDir>
#include <QtSerialPort>

#include <osvr/USBSerial/USBSerialEnum.h>
#include <osvr/USBSerial/USBSerialDevice.h>
#include <ios>

#include "json/json.h"

// Helper function for validating numerical input
Expand Down Expand Up @@ -444,8 +448,20 @@ void MainWindow::writeSerialData(QSerialPort *thePort, const QByteArray &data)
}

QSerialPort* MainWindow::findAndOpenSerialPort() {
// find the OSVR HDK and get current FW version
QString portName = MainWindow::findSerialPort(0x1532, 0x0B00);
QString portName = QString("Not found");
for (auto &&dev : osvr::usbserial::enumerate()) {
if (m_verbose) {
std::cout << "Checking serial device " << hex << dev.getVID() << ":" << hex << dev.getPID() <<
" -> " << dev.getPlatformSpecificPath() << std::endl;
}

if (dev.getVID() == 0x1532 && dev.getPID() == 0x0B00) {
if (m_verbose) {
std::cout << "Found serial device: " << dev.getPlatformSpecificPath() << std::endl;
}
portName = QString::fromStdString(dev.getPlatformSpecificPath());
}
}
if (portName != "Not found"){
QSerialPort *thePort = openSerialPort(portName);
return thePort;
Expand Down

0 comments on commit a2303e1

Please sign in to comment.