Enabled ability to use any QT SerialBus driver in SavvyCAN. Now
PeakCAN, ValueCAN, SocketCAN, and J2534 should all work.
This commit is contained in:
@@ -16,7 +16,7 @@ namespace CANCon {
|
|||||||
{
|
{
|
||||||
GVRET_SERIAL,
|
GVRET_SERIAL,
|
||||||
KVASER,
|
KVASER,
|
||||||
SOCKETCAN,
|
SERIALBUS,
|
||||||
REMOTE,
|
REMOTE,
|
||||||
NONE
|
NONE
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
using namespace CANCon;
|
using namespace CANCon;
|
||||||
|
|
||||||
CANConnection* CanConFactory::create(type pType, QString pPortName)
|
CANConnection* CanConFactory::create(type pType, QString pPortName, QString pDriverName)
|
||||||
{
|
{
|
||||||
switch(pType) {
|
switch(pType) {
|
||||||
case SOCKETCAN:
|
case SERIALBUS:
|
||||||
return new SerialBusConnection(pPortName);
|
return new SerialBusConnection(pPortName, pDriverName);
|
||||||
case GVRET_SERIAL:
|
case GVRET_SERIAL:
|
||||||
return new GVRetSerial(pPortName, false);
|
return new GVRetSerial(pPortName, false);
|
||||||
case REMOTE:
|
case REMOTE:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
class CanConFactory
|
class CanConFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CANConnection* create(CANCon::type, QString pPortName);
|
static CANConnection* create(CANCon::type, QString pPortName, QString pDriverName);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CANCONFACTORY_H
|
#endif // CANCONFACTORY_H
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "canconnection.h"
|
#include "canconnection.h"
|
||||||
|
|
||||||
CANConnection::CANConnection(QString pPort,
|
CANConnection::CANConnection(QString pPort,
|
||||||
|
QString pDriver,
|
||||||
CANCon::type pType,
|
CANCon::type pType,
|
||||||
int pNumBuses,
|
int pNumBuses,
|
||||||
int pQueueLen,
|
int pQueueLen,
|
||||||
@@ -10,6 +11,7 @@ CANConnection::CANConnection(QString pPort,
|
|||||||
mQueue(),
|
mQueue(),
|
||||||
mNumBuses(pNumBuses),
|
mNumBuses(pNumBuses),
|
||||||
mPort(pPort),
|
mPort(pPort),
|
||||||
|
mDriver(pDriver),
|
||||||
mType(pType),
|
mType(pType),
|
||||||
mIsCapSuspended(false),
|
mIsCapSuspended(false),
|
||||||
mStatus(CANCon::NOT_CONNECTED),
|
mStatus(CANCon::NOT_CONNECTED),
|
||||||
@@ -227,6 +229,10 @@ QString CANConnection::getPort() {
|
|||||||
return mPort;
|
return mPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CANConnection::getDriver()
|
||||||
|
{
|
||||||
|
return mDriver;
|
||||||
|
}
|
||||||
|
|
||||||
LFQueue<CANFrame>& CANConnection::getQueue() {
|
LFQueue<CANFrame>& CANConnection::getQueue() {
|
||||||
return mQueue;
|
return mQueue;
|
||||||
|
|||||||
@@ -19,12 +19,14 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* @brief CANConnection constructor
|
* @brief CANConnection constructor
|
||||||
* @param pPort: string containing port name
|
* @param pPort: string containing port name
|
||||||
|
* @param pDriver: string containing driver name - Really only used for SerialBus connections
|
||||||
* @param pType: the type of connection @ref CANCon::type
|
* @param pType: the type of connection @ref CANCon::type
|
||||||
* @param pNumBuses: the number of buses the device has
|
* @param pNumBuses: the number of buses the device has
|
||||||
* @param pQueueLen: the length of the lock free queue to use
|
* @param pQueueLen: the length of the lock free queue to use
|
||||||
* @param pUseThread: if set to true, object will be execute in a dedicated thread
|
* @param pUseThread: if set to true, object will be execute in a dedicated thread
|
||||||
*/
|
*/
|
||||||
CANConnection(QString pPort,
|
CANConnection(QString pPort,
|
||||||
|
QString pDriver,
|
||||||
CANCon::type pType,
|
CANCon::type pType,
|
||||||
int pNumBuses,
|
int pNumBuses,
|
||||||
int pQueueLen,
|
int pQueueLen,
|
||||||
@@ -50,6 +52,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
QString getPort();
|
QString getPort();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief getDriver
|
||||||
|
* @return returns the name of the driver used for this device
|
||||||
|
*/
|
||||||
|
QString getDriver();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief getQueue
|
* @brief getQueue
|
||||||
* @return the lock free queue of the device
|
* @return the lock free queue of the device
|
||||||
@@ -294,6 +303,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
LFQueue<CANFrame> mQueue;
|
LFQueue<CANFrame> mQueue;
|
||||||
const QString mPort;
|
const QString mPort;
|
||||||
|
const QString mDriver;
|
||||||
const CANCon::type mType;
|
const CANCon::type mType;
|
||||||
bool mIsCapSuspended;
|
bool mIsCapSuspended;
|
||||||
QAtomicInt mStatus;
|
QAtomicInt mStatus;
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const
|
|||||||
bool ret;
|
bool ret;
|
||||||
if (!conn_p) return QVariant();
|
if (!conn_p) return QVariant();
|
||||||
ret = conn_p->getBusSettings(busId, bus);
|
ret = conn_p->getBusSettings(busId, bus);
|
||||||
bool isSocketCAN = (conn_p->getType() == CANCon::SOCKETCAN) ? true: false;
|
bool isSocketCAN = (conn_p->getType() == CANCon::SERIALBUS) ? true: false;
|
||||||
|
|
||||||
//qDebug() << "ConnP: " << conn_p << " ret " << ret;
|
//qDebug() << "ConnP: " << conn_p << " ret " << ret;
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const
|
|||||||
if (conn_p)
|
if (conn_p)
|
||||||
switch (conn_p->getType()) {
|
switch (conn_p->getType()) {
|
||||||
case CANCon::KVASER: return "KVASER";
|
case CANCon::KVASER: return "KVASER";
|
||||||
case CANCon::SOCKETCAN: return "SocketCAN";
|
case CANCon::SERIALBUS: return "SerialBus";
|
||||||
case CANCon::GVRET_SERIAL: return "GVRET";
|
case CANCon::GVRET_SERIAL: return "GVRET";
|
||||||
default: {}
|
default: {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,16 +43,13 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
|
|||||||
/* load connection configuration */
|
/* load connection configuration */
|
||||||
loadConnections();
|
loadConnections();
|
||||||
|
|
||||||
ui->rbSocketCAN->setEnabled(isSocketCanAvailable());
|
ui->rbSocketCAN->setEnabled(isSerialBusAvailable());
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
ui->rbKvaser->setEnabled(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
connect(ui->btnOK, &QAbstractButton::clicked, this, &ConnectionWindow::handleOKButton);
|
connect(ui->btnOK, &QAbstractButton::clicked, this, &ConnectionWindow::handleOKButton);
|
||||||
connect(ui->rbGVRET, &QAbstractButton::clicked, this, &ConnectionWindow::handleConnTypeChanged);
|
connect(ui->rbGVRET, &QAbstractButton::clicked, this, &ConnectionWindow::handleConnTypeChanged);
|
||||||
connect(ui->rbKvaser, &QAbstractButton::clicked, this, &ConnectionWindow::handleConnTypeChanged);
|
|
||||||
connect(ui->rbSocketCAN, &QAbstractButton::clicked, this, &ConnectionWindow::handleConnTypeChanged);
|
connect(ui->rbSocketCAN, &QAbstractButton::clicked, this, &ConnectionWindow::handleConnTypeChanged);
|
||||||
connect(ui->rbRemote, &QAbstractButton::clicked, this, &ConnectionWindow::handleConnTypeChanged);
|
connect(ui->rbRemote, &QAbstractButton::clicked, this, &ConnectionWindow::handleConnTypeChanged);
|
||||||
|
connect(ui->cbDeviceType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ConnectionWindow::handleDeviceTypeChanged);
|
||||||
connect(ui->tableConnections->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &ConnectionWindow::currentRowChanged);
|
connect(ui->tableConnections->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &ConnectionWindow::currentRowChanged);
|
||||||
connect(ui->btnActivateAll, &QPushButton::clicked, this, &ConnectionWindow::handleEnableAll);
|
connect(ui->btnActivateAll, &QPushButton::clicked, this, &ConnectionWindow::handleEnableAll);
|
||||||
connect(ui->btnDeactivateAll, &QPushButton::clicked, this, &ConnectionWindow::handleDisableAll);
|
connect(ui->btnDeactivateAll, &QPushButton::clicked, this, &ConnectionWindow::handleDisableAll);
|
||||||
@@ -62,6 +59,9 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
|
|||||||
connect(ui->btnSendHex, &QPushButton::clicked, this, &ConnectionWindow::handleSendHex);
|
connect(ui->btnSendHex, &QPushButton::clicked, this, &ConnectionWindow::handleSendHex);
|
||||||
connect(ui->btnSendText, &QPushButton::clicked, this, &ConnectionWindow::handleSendText);
|
connect(ui->btnSendText, &QPushButton::clicked, this, &ConnectionWindow::handleSendText);
|
||||||
connect(ui->ckEnableConsole, &QCheckBox::toggled, this, &ConnectionWindow::consoleEnableChanged);
|
connect(ui->ckEnableConsole, &QCheckBox::toggled, this, &ConnectionWindow::consoleEnableChanged);
|
||||||
|
|
||||||
|
ui->lblDeviceType->setHidden(true);
|
||||||
|
ui->cbDeviceType->setHidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionWindow::~ConnectionWindow()
|
ConnectionWindow::~ConnectionWindow()
|
||||||
@@ -117,7 +117,7 @@ bool ConnectionWindow::eventFilter(QObject *obj, QEvent *event)
|
|||||||
// standard event processing
|
// standard event processing
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
return false;
|
//return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionWindow::readSettings()
|
void ConnectionWindow::readSettings()
|
||||||
@@ -199,7 +199,7 @@ void ConnectionWindow::consoleEnableChanged(bool checked) {
|
|||||||
connect(this, SIGNAL(sendDebugData(QByteArray)), conn_p, SLOT(debugInput(QByteArray)));
|
connect(this, SIGNAL(sendDebugData(QByteArray)), conn_p, SLOT(debugInput(QByteArray)));
|
||||||
}
|
}
|
||||||
else { //turn it off
|
else { //turn it off
|
||||||
disconnect(conn_p, SIGNAL(debugOutput(QString)), 0, 0);
|
disconnect(conn_p, SIGNAL(debugOutput(QString)), nullptr, nullptr);
|
||||||
disconnect(this, SIGNAL(sendDebugData(QByteArray)), conn_p, SLOT(debugInput(QByteArray)));
|
disconnect(this, SIGNAL(sendDebugData(QByteArray)), conn_p, SLOT(debugInput(QByteArray)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,11 +225,18 @@ void ConnectionWindow::handleDisableAll()
|
|||||||
void ConnectionWindow::handleConnTypeChanged()
|
void ConnectionWindow::handleConnTypeChanged()
|
||||||
{
|
{
|
||||||
if (ui->rbGVRET->isChecked()) selectSerial();
|
if (ui->rbGVRET->isChecked()) selectSerial();
|
||||||
if (ui->rbKvaser->isChecked()) selectKvaser();
|
|
||||||
if (ui->rbSocketCAN->isChecked()) selectSocketCan();
|
if (ui->rbSocketCAN->isChecked()) selectSocketCan();
|
||||||
if (ui->rbRemote->isChecked()) selectRemote();
|
if (ui->rbRemote->isChecked()) selectRemote();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectionWindow::handleDeviceTypeChanged()
|
||||||
|
{
|
||||||
|
ui->cbPort->clear();
|
||||||
|
canDevices = QCanBus::instance()->availableDevices(ui->cbDeviceType->currentText());
|
||||||
|
|
||||||
|
for (int i = 0; i < canDevices.count(); i++)
|
||||||
|
ui->cbPort->addItem(canDevices[i].name());
|
||||||
|
}
|
||||||
|
|
||||||
/* status */
|
/* status */
|
||||||
void ConnectionWindow::connectionStatus(CANConStatus pStatus)
|
void ConnectionWindow::connectionStatus(CANConStatus pStatus)
|
||||||
@@ -243,12 +250,12 @@ void ConnectionWindow::connectionStatus(CANConStatus pStatus)
|
|||||||
|
|
||||||
void ConnectionWindow::handleOKButton()
|
void ConnectionWindow::handleOKButton()
|
||||||
{
|
{
|
||||||
CANConnection* conn_p = NULL;
|
CANConnection* conn_p = nullptr;
|
||||||
|
|
||||||
if( ! CANConManager::getInstance()->getByName(getPortName()) )
|
if( ! CANConManager::getInstance()->getByName(getPortName()) )
|
||||||
{
|
{
|
||||||
/* create connection */
|
/* create connection */
|
||||||
conn_p = create(getConnectionType(), getPortName());
|
conn_p = create(getConnectionType(), getPortName(), getDriverName());
|
||||||
if(!conn_p)
|
if(!conn_p)
|
||||||
return;
|
return;
|
||||||
/* add connection to model */
|
/* add connection to model */
|
||||||
@@ -280,7 +287,7 @@ return;
|
|||||||
ui->btnOK->setText(tr("Create New Connection"));
|
ui->btnOK->setText(tr("Create New Connection"));
|
||||||
ui->rbGVRET->setChecked(true);
|
ui->rbGVRET->setChecked(true);
|
||||||
setSpeed(0);
|
setSpeed(0);
|
||||||
setPortName(CANCon::GVRET_SERIAL, "");
|
setPortName(CANCon::GVRET_SERIAL, "", "");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -299,7 +306,7 @@ return;
|
|||||||
|
|
||||||
ui->btnOK->setText(tr("Update Connection Settings"));
|
ui->btnOK->setText(tr("Update Connection Settings"));
|
||||||
setSpeed(bus.getSpeed());
|
setSpeed(bus.getSpeed());
|
||||||
setPortName(conn_p->getType(), conn_p->getPort());
|
setPortName(conn_p->getType(), conn_p->getPort(), conn_p->getDriver());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,6 +339,8 @@ void ConnectionWindow::selectSerial()
|
|||||||
ui->lPort->setText("Port:");
|
ui->lPort->setText("Port:");
|
||||||
/* set combobox page visible */
|
/* set combobox page visible */
|
||||||
ui->stPort->setCurrentWidget(ui->cbPage);
|
ui->stPort->setCurrentWidget(ui->cbPage);
|
||||||
|
ui->lblDeviceType->setHidden(true);
|
||||||
|
ui->cbDeviceType->setHidden(true);
|
||||||
|
|
||||||
ui->cbPort->clear();
|
ui->cbPort->clear();
|
||||||
ports = QSerialPortInfo::availablePorts();
|
ports = QSerialPortInfo::availablePorts();
|
||||||
@@ -340,41 +349,42 @@ void ConnectionWindow::selectSerial()
|
|||||||
ui->cbPort->addItem(ports[i].portName());
|
ui->cbPort->addItem(ports[i].portName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionWindow::selectKvaser()
|
|
||||||
{
|
|
||||||
ui->lPort->setText("Port:");
|
|
||||||
/* set combobox page visible */
|
|
||||||
ui->stPort->setCurrentWidget(ui->cbPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionWindow::selectSocketCan()
|
void ConnectionWindow::selectSocketCan()
|
||||||
{
|
{
|
||||||
ui->lPort->setText("Port:");
|
ui->lPort->setText("Port:");
|
||||||
/* set edit text page visible */
|
/* set edit text page visible */
|
||||||
ui->stPort->setCurrentWidget(ui->etPage);
|
ui->stPort->setCurrentWidget(ui->cbPage);
|
||||||
|
ui->lblDeviceType->setHidden(false);
|
||||||
|
ui->cbDeviceType->setHidden(false);
|
||||||
|
|
||||||
|
ui->cbDeviceType->clear();
|
||||||
|
QStringList plugins;
|
||||||
|
plugins = QCanBus::instance()->plugins();
|
||||||
|
for (int i = 0; i < plugins.count(); i++)
|
||||||
|
ui->cbDeviceType->addItem(plugins[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionWindow::selectRemote()
|
void ConnectionWindow::selectRemote()
|
||||||
{
|
{
|
||||||
ui->lPort->setText("IP Address:");
|
ui->lPort->setText("IP Address:");
|
||||||
ui->stPort->setCurrentWidget(ui->etPage);
|
ui->stPort->setCurrentWidget(ui->etPage);
|
||||||
|
ui->lblDeviceType->setHidden(true);
|
||||||
|
ui->cbDeviceType->setHidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionWindow::setSpeed(int speed0)
|
void ConnectionWindow::setSpeed(int speed0)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(speed0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionWindow::setPortName(CANCon::type pType, QString pPortName)
|
void ConnectionWindow::setPortName(CANCon::type pType, QString pPortName, QString pDriver)
|
||||||
{
|
{
|
||||||
switch(pType)
|
switch(pType)
|
||||||
{
|
{
|
||||||
case CANCon::GVRET_SERIAL:
|
case CANCon::GVRET_SERIAL:
|
||||||
ui->rbGVRET->setChecked(true);
|
ui->rbGVRET->setChecked(true);
|
||||||
break;
|
break;
|
||||||
case CANCon::KVASER:
|
case CANCon::SERIALBUS:
|
||||||
ui->rbKvaser->setChecked(true);
|
|
||||||
break;
|
|
||||||
case CANCon::SOCKETCAN:
|
|
||||||
ui->rbSocketCAN->setChecked(true);
|
ui->rbSocketCAN->setChecked(true);
|
||||||
//you can't configure any of the below three with socketcan so dim them out
|
//you can't configure any of the below three with socketcan so dim them out
|
||||||
break;
|
break;
|
||||||
@@ -393,7 +403,16 @@ void ConnectionWindow::setPortName(CANCon::type pType, QString pPortName)
|
|||||||
ui->cbPort->setCurrentIndex(idx);
|
ui->cbPort->setCurrentIndex(idx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CANCon::SOCKETCAN:
|
case CANCon::SERIALBUS:
|
||||||
|
{
|
||||||
|
int idx = ui->cbDeviceType->findText(pDriver);
|
||||||
|
if (idx < 0) idx = 0;
|
||||||
|
ui->cbDeviceType->setCurrentIndex(idx);
|
||||||
|
idx = ui->cbPort->findText(pPortName);
|
||||||
|
if( idx < 0 ) idx = 0;
|
||||||
|
ui->cbPort->setCurrentIndex(idx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CANCon::REMOTE:
|
case CANCon::REMOTE:
|
||||||
{
|
{
|
||||||
ui->lePort->setText(pPortName);
|
ui->lePort->setText(pPortName);
|
||||||
@@ -414,9 +433,8 @@ QString ConnectionWindow::getPortName()
|
|||||||
{
|
{
|
||||||
switch( getConnectionType() ) {
|
switch( getConnectionType() ) {
|
||||||
case CANCon::GVRET_SERIAL:
|
case CANCon::GVRET_SERIAL:
|
||||||
case CANCon::KVASER:
|
case CANCon::SERIALBUS:
|
||||||
return ui->cbPort->currentText();
|
return ui->cbPort->currentText();
|
||||||
case CANCon::SOCKETCAN:
|
|
||||||
case CANCon::REMOTE:
|
case CANCon::REMOTE:
|
||||||
return ui->lePort->text();
|
return ui->lePort->text();
|
||||||
default:
|
default:
|
||||||
@@ -426,11 +444,20 @@ QString ConnectionWindow::getPortName()
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ConnectionWindow::getDriverName()
|
||||||
|
{
|
||||||
|
if (getConnectionType() == CANCon::SERIALBUS)
|
||||||
|
{
|
||||||
|
return ui->cbDeviceType->currentText();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
CANCon::type ConnectionWindow::getConnectionType()
|
CANCon::type ConnectionWindow::getConnectionType()
|
||||||
{
|
{
|
||||||
if (ui->rbGVRET->isChecked()) return CANCon::GVRET_SERIAL;
|
if (ui->rbGVRET->isChecked()) return CANCon::GVRET_SERIAL;
|
||||||
if (ui->rbKvaser->isChecked()) return CANCon::KVASER;
|
if (ui->rbSocketCAN->isChecked()) return CANCon::SERIALBUS;
|
||||||
if (ui->rbSocketCAN->isChecked()) return CANCon::SOCKETCAN;
|
|
||||||
if (ui->rbRemote->isChecked()) return CANCon::REMOTE;
|
if (ui->rbRemote->isChecked()) return CANCon::REMOTE;
|
||||||
qDebug() << "getConnectionType: error";
|
qDebug() << "getConnectionType: error";
|
||||||
return CANCon::NONE;
|
return CANCon::NONE;
|
||||||
@@ -439,6 +466,7 @@ CANCon::type ConnectionWindow::getConnectionType()
|
|||||||
|
|
||||||
void ConnectionWindow::setSWMode(bool mode)
|
void ConnectionWindow::setSWMode(bool mode)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConnectionWindow::getSWMode()
|
bool ConnectionWindow::getSWMode()
|
||||||
@@ -474,21 +502,19 @@ void ConnectionWindow::handleRevert()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ConnectionWindow::isSocketCanAvailable()
|
bool ConnectionWindow::isSerialBusAvailable()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_LINUX
|
if (QCanBus::instance()->plugins().count() > 0) return true;
|
||||||
if (QCanBus::instance()->plugins().contains(QStringLiteral("socketcan"))) return true;
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CANConnection* ConnectionWindow::create(CANCon::type pTye, QString pPortName)
|
CANConnection* ConnectionWindow::create(CANCon::type pTye, QString pPortName, QString pDriver)
|
||||||
{
|
{
|
||||||
CANConnection* conn_p;
|
CANConnection* conn_p;
|
||||||
|
|
||||||
/* create connection */
|
/* create connection */
|
||||||
conn_p = CanConFactory::create(pTye, pPortName);
|
conn_p = CanConFactory::create(pTye, pPortName, pDriver);
|
||||||
if(conn_p)
|
if(conn_p)
|
||||||
{
|
{
|
||||||
/* connect signal */
|
/* connect signal */
|
||||||
@@ -511,11 +537,12 @@ void ConnectionWindow::loadConnections()
|
|||||||
|
|
||||||
/* fill connection list */
|
/* fill connection list */
|
||||||
QVector<QString> portNames = settings.value("connections/portNames").value<QVector<QString>>();
|
QVector<QString> portNames = settings.value("connections/portNames").value<QVector<QString>>();
|
||||||
|
QVector<QString> driverNames = settings.value("connections/driverNames").value<QVector<QString>>();
|
||||||
QVector<int> devTypes = settings.value("connections/types").value<QVector<int>>();
|
QVector<int> devTypes = settings.value("connections/types").value<QVector<int>>();
|
||||||
|
|
||||||
for(int i = 0 ; i < portNames.count() ; i++)
|
for(int i = 0 ; i < portNames.count() ; i++)
|
||||||
{
|
{
|
||||||
CANConnection* conn_p = create((CANCon::type)devTypes[i], portNames[i]);
|
CANConnection* conn_p = create((CANCon::type)devTypes[i], portNames[i], driverNames[i]);
|
||||||
/* add connection to model */
|
/* add connection to model */
|
||||||
connModel->add(conn_p);
|
connModel->add(conn_p);
|
||||||
}
|
}
|
||||||
@@ -532,14 +559,17 @@ void ConnectionWindow::saveConnections()
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
QVector<QString> portNames;
|
QVector<QString> portNames;
|
||||||
QVector<int> devTypes;
|
QVector<int> devTypes;
|
||||||
|
QVector<QString> driverNames;
|
||||||
|
|
||||||
/* save connections */
|
/* save connections */
|
||||||
foreach(CANConnection* conn_p, conns)
|
foreach(CANConnection* conn_p, conns)
|
||||||
{
|
{
|
||||||
portNames.append(conn_p->getPort());
|
portNames.append(conn_p->getPort());
|
||||||
devTypes.append(conn_p->getType());
|
devTypes.append(conn_p->getType());
|
||||||
|
driverNames.append(conn_p->getDriver());
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.setValue("connections/portNames", QVariant::fromValue(portNames));
|
settings.setValue("connections/portNames", QVariant::fromValue(portNames));
|
||||||
settings.setValue("connections/types", QVariant::fromValue(devTypes));
|
settings.setValue("connections/types", QVariant::fromValue(devTypes));
|
||||||
|
settings.setValue("connections/driverNames", QVariant::fromValue(driverNames));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QItemSelection>
|
#include <QItemSelection>
|
||||||
|
#include <QCanBusDeviceInfo>
|
||||||
#include "canconnectionmodel.h"
|
#include "canconnectionmodel.h"
|
||||||
#include "connections/canconnection.h"
|
#include "connections/canconnection.h"
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void handleOKButton();
|
void handleOKButton();
|
||||||
void handleConnTypeChanged();
|
void handleConnTypeChanged();
|
||||||
|
void handleDeviceTypeChanged();
|
||||||
void currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
void currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
void consoleEnableChanged(bool checked);
|
void consoleEnableChanged(bool checked);
|
||||||
void handleRemoveConn();
|
void handleRemoveConn();
|
||||||
@@ -63,6 +65,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
Ui::ConnectionWindow *ui;
|
Ui::ConnectionWindow *ui;
|
||||||
QList<QSerialPortInfo> ports;
|
QList<QSerialPortInfo> ports;
|
||||||
|
QList<QCanBusDeviceInfo> canDevices;
|
||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
CANConnectionModel *connModel;
|
CANConnectionModel *connModel;
|
||||||
|
|
||||||
@@ -70,13 +73,14 @@ private:
|
|||||||
void selectKvaser();
|
void selectKvaser();
|
||||||
void selectSocketCan();
|
void selectSocketCan();
|
||||||
void selectRemote();
|
void selectRemote();
|
||||||
bool isSocketCanAvailable();
|
bool isSerialBusAvailable();
|
||||||
int getSpeed();
|
int getSpeed();
|
||||||
QString getPortName();
|
QString getPortName();
|
||||||
void setPortName(CANCon::type pType, QString pPortName);
|
QString getDriverName();
|
||||||
|
void setPortName(CANCon::type pType, QString pPortName, QString pDriver);
|
||||||
|
|
||||||
void setActiveAll(bool pActive);
|
void setActiveAll(bool pActive);
|
||||||
CANConnection* create(CANCon::type pTye, QString pPortName);
|
CANConnection* create(CANCon::type pTye, QString pPortName, QString pDriver);
|
||||||
void loadConnections();
|
void loadConnections();
|
||||||
void saveConnections();
|
void saveConnections();
|
||||||
void showEvent(QShowEvent *);
|
void showEvent(QShowEvent *);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "gvretserial.h"
|
#include "gvretserial.h"
|
||||||
|
|
||||||
GVRetSerial::GVRetSerial(QString portName, bool useTcp) :
|
GVRetSerial::GVRetSerial(QString portName, bool useTcp) :
|
||||||
CANConnection(portName, CANCon::GVRET_SERIAL, 3, 4000, true),
|
CANConnection(portName, "gvret", CANCon::GVRET_SERIAL, 3, 4000, true),
|
||||||
useTcp(useTcp),
|
useTcp(useTcp),
|
||||||
mTimer(this) /*NB: set this as parent of timer to manage it from working thread */
|
mTimer(this) /*NB: set this as parent of timer to manage it from working thread */
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
/**** class definition ****/
|
/**** class definition ****/
|
||||||
/***********************************/
|
/***********************************/
|
||||||
|
|
||||||
SerialBusConnection::SerialBusConnection(QString portName) :
|
SerialBusConnection::SerialBusConnection(QString portName, QString driverName) :
|
||||||
CANConnection(portName, CANCon::SOCKETCAN, 1, 4000, true),
|
CANConnection(portName, driverName, CANCon::SERIALBUS, 1, 4000, true),
|
||||||
mTimer(this) /*NB: set connection as parent of timer to manage it from working thread */
|
mTimer(this) /*NB: set connection as parent of timer to manage it from working thread */
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -77,10 +77,10 @@ void SerialBusConnection::piSetBusSettings(int pBusIdx, CANBus bus)
|
|||||||
|
|
||||||
/* create device */
|
/* create device */
|
||||||
QString errorString;
|
QString errorString;
|
||||||
mDev_p = QCanBus::instance()->createDevice("socketcan", getPort(), &errorString);
|
mDev_p = QCanBus::instance()->createDevice(getDriver(), getPort(), &errorString);
|
||||||
if (!mDev_p) {
|
if (!mDev_p) {
|
||||||
disconnectDevice();
|
disconnectDevice();
|
||||||
qDebug() << "Error: createDevice(" << getType() << getPort() << "):" << errorString;
|
qDebug() << "Error: createDevice(" << getType() << getDriver() << getPort() << "):" << errorString;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class SerialBusConnection : public CANConnection
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SerialBusConnection(QString portName);
|
SerialBusConnection(QString portName, QString driverName);
|
||||||
virtual ~SerialBusConnection();
|
virtual ~SerialBusConnection();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
+13
-13
@@ -81,16 +81,6 @@
|
|||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QRadioButton" name="rbKvaser">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Kvaser</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QRadioButton" name="rbGVRET">
|
<widget class="QRadioButton" name="rbGVRET">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -101,17 +91,17 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QRadioButton" name="rbSocketCAN">
|
<widget class="QRadioButton" name="rbSocketCAN">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>SocketCAN</string>
|
<string>QT SerialBus Devices (SocketCAN, PeakCAN, etc)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="0">
|
||||||
<widget class="QRadioButton" name="rbRemote">
|
<widget class="QRadioButton" name="rbRemote">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Remote Host</string>
|
<string>Remote Host</string>
|
||||||
@@ -121,6 +111,16 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblDeviceType">
|
||||||
|
<property name="text">
|
||||||
|
<string>Device Type:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="cbDeviceType"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="lPort">
|
<widget class="QLabel" name="lPort">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|||||||
Reference in New Issue
Block a user