Some progress toward supporting socketcan connections
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets serialport printsupport
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets serialport printsupport network
|
||||
|
||||
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
|
||||
|
||||
|
||||
+24
-1
@@ -1,5 +1,6 @@
|
||||
#include "connectionwindow.h"
|
||||
#include "ui_connectionwindow.h"
|
||||
#include <QtNetwork/QNetworkInterface>
|
||||
|
||||
ConnectionWindow::ConnectionWindow(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@@ -7,7 +8,8 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
getSerialPorts();
|
||||
//getSerialPorts();
|
||||
getSocketcanPorts();
|
||||
|
||||
ui->cbSpeed0->addItem(tr("<Default>"));
|
||||
ui->cbSpeed0->addItem(tr("Disabled"));
|
||||
@@ -25,6 +27,14 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
|
||||
ui->cbSpeed1->addItem(tr("1000000"));
|
||||
ui->cbSpeed1->addItem(tr("33333"));
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
ui->rbSocketCAN->setEnabled(true);
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
ui->rbKvaser->setEnabled(true);
|
||||
#endif
|
||||
|
||||
connect(ui->btnOK, SIGNAL(clicked(bool)), this, SLOT(handleOKButton()));
|
||||
}
|
||||
|
||||
@@ -73,7 +83,20 @@ void ConnectionWindow::getKvaserPorts()
|
||||
|
||||
void ConnectionWindow::getSocketcanPorts()
|
||||
{
|
||||
QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
|
||||
QString interfaceName;
|
||||
|
||||
ui->cbPort->clear();
|
||||
|
||||
foreach (QNetworkInterface interface, interfaces)
|
||||
{
|
||||
interfaceName = interface.name().toLower();
|
||||
qDebug() << "Interface: " << interface.name();
|
||||
if (interfaceName.contains("can"))
|
||||
{
|
||||
ui->cbPort->addItem(interfaceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionWindow::setSpeeds(int speed0, int speed1)
|
||||
|
||||
Reference in New Issue
Block a user