CAN-FD
This commit is contained in:
@@ -21,6 +21,7 @@ ICON = icons/SavvyIcon.icns
|
|||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += main.cpp\
|
||||||
canbridgewindow.cpp \
|
canbridgewindow.cpp \
|
||||||
|
connections/canlogserver.cpp \
|
||||||
connections/canserver.cpp \
|
connections/canserver.cpp \
|
||||||
connections/lawicel_serial.cpp \
|
connections/lawicel_serial.cpp \
|
||||||
connections/mqtt_bus.cpp \
|
connections/mqtt_bus.cpp \
|
||||||
@@ -104,6 +105,7 @@ HEADERS += mainwindow.h \
|
|||||||
can_structs.h \
|
can_structs.h \
|
||||||
canbridgewindow.h \
|
canbridgewindow.h \
|
||||||
canframemodel.h \
|
canframemodel.h \
|
||||||
|
connections/canlogserver.h \
|
||||||
connections/canserver.h \
|
connections/canserver.h \
|
||||||
connections/lawicel_serial.h \
|
connections/lawicel_serial.h \
|
||||||
connections/socketcand.h \
|
connections/socketcand.h \
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace CANCon {
|
|||||||
MQTT,
|
MQTT,
|
||||||
LAWICEL,
|
LAWICEL,
|
||||||
CANSERVER,
|
CANSERVER,
|
||||||
|
CANLOGSERVER,
|
||||||
NONE
|
NONE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "socketcand.h"
|
#include "socketcand.h"
|
||||||
#include "lawicel_serial.h"
|
#include "lawicel_serial.h"
|
||||||
#include "canserver.h"
|
#include "canserver.h"
|
||||||
|
#include "canlogserver.h"
|
||||||
|
|
||||||
using namespace CANCon;
|
using namespace CANCon;
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ CANConnection* CanConFactory::create(type pType, QString pPortName, QString pDri
|
|||||||
return new MQTT_BUS(pPortName);
|
return new MQTT_BUS(pPortName);
|
||||||
case CANSERVER:
|
case CANSERVER:
|
||||||
return new CANserver(pPortName);
|
return new CANserver(pPortName);
|
||||||
|
case CANLOGSERVER:
|
||||||
|
return new CanLogServer(pPortName);
|
||||||
default: {}
|
default: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const
|
|||||||
case CANCon::KAYAK: return "socketcand";
|
case CANCon::KAYAK: return "socketcand";
|
||||||
case CANCon::LAWICEL: return "LAWICEL";
|
case CANCon::LAWICEL: return "LAWICEL";
|
||||||
case CANCon::CANSERVER: return "CANserver";
|
case CANCon::CANSERVER: return "CANserver";
|
||||||
|
case CANCon::CANLOGSERVER: return "CanLogServer";
|
||||||
default: {}
|
default: {}
|
||||||
}
|
}
|
||||||
else qDebug() << "Tried to show connection type but connection was nullptr";
|
else qDebug() << "Tried to show connection type but connection was nullptr";
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "canlogserver.h"
|
#include "canlogserver.h"
|
||||||
|
|
||||||
CanLogServer::CanLogServer(QString serverAddressString) :
|
CanLogServer::CanLogServer(QString serverAddressString) :
|
||||||
CANConnection(serverAddressString, "CanLogserver", CANCon::CANLOGSERVER, 0, 0, 1, 4000, true),
|
CANConnection(serverAddressString, "CanLogserver", CANCon::CANLOGSERVER, 0, 0, false, 0, 1, 4000, true),
|
||||||
m_ptcpSocket(new QTcpSocket(this))
|
m_ptcpSocket(new QTcpSocket(this))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ NewConnectionDialog::NewConnectionDialog(QVector<QString>* gvretips, QVector<QSt
|
|||||||
connect(ui->rbMQTT, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
|
connect(ui->rbMQTT, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
|
||||||
connect(ui->rbLawicel, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
|
connect(ui->rbLawicel, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
|
||||||
connect(ui->rbCANserver, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
|
connect(ui->rbCANserver, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
|
||||||
|
connect(ui->rbCanlogserver, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
|
||||||
|
|
||||||
connect(ui->cbDeviceType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &NewConnectionDialog::handleDeviceTypeChanged);
|
connect(ui->cbDeviceType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &NewConnectionDialog::handleDeviceTypeChanged);
|
||||||
connect(ui->btnOK, &QPushButton::clicked, this, &NewConnectionDialog::handleCreateButton);
|
connect(ui->btnOK, &QPushButton::clicked, this, &NewConnectionDialog::handleCreateButton);
|
||||||
@@ -68,6 +69,7 @@ void NewConnectionDialog::handleConnTypeChanged()
|
|||||||
if (ui->rbKayak->isChecked()) selectKayak();
|
if (ui->rbKayak->isChecked()) selectKayak();
|
||||||
if (ui->rbMQTT->isChecked()) selectMQTT();
|
if (ui->rbMQTT->isChecked()) selectMQTT();
|
||||||
if (ui->rbCANserver->isChecked()) selectCANserver();
|
if (ui->rbCANserver->isChecked()) selectCANserver();
|
||||||
|
if (ui->rbCanlogserver->isChecked()) selectCANlogserver();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewConnectionDialog::handleDeviceTypeChanged()
|
void NewConnectionDialog::handleDeviceTypeChanged()
|
||||||
@@ -250,6 +252,23 @@ void NewConnectionDialog::selectCANserver()
|
|||||||
ui->cbPort->clear();
|
ui->cbPort->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NewConnectionDialog::selectCANlogserver()
|
||||||
|
{
|
||||||
|
ui->lPort->setText("CANlogserver IP Address:");
|
||||||
|
|
||||||
|
ui->lblDeviceType->setHidden(true);
|
||||||
|
ui->cbDeviceType->setHidden(true);
|
||||||
|
ui->cbCANSpeed->setHidden(true);
|
||||||
|
ui->cbSerialSpeed->setHidden(true);
|
||||||
|
ui->lblCANSpeed->setHidden(true);
|
||||||
|
ui->lblSerialSpeed->setHidden(true);
|
||||||
|
ui->cbCanFd->setHidden(true);
|
||||||
|
ui->cbDataRate->setHidden(true);
|
||||||
|
ui->lblDataRate->setHidden(true);
|
||||||
|
|
||||||
|
ui->cbPort->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void NewConnectionDialog::setPortName(CANCon::type pType, QString pPortName, QString pDriver)
|
void NewConnectionDialog::setPortName(CANCon::type pType, QString pPortName, QString pDriver)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -276,6 +295,9 @@ void NewConnectionDialog::setPortName(CANCon::type pType, QString pPortName, QSt
|
|||||||
case CANCon::CANSERVER:
|
case CANCon::CANSERVER:
|
||||||
ui->rbCANserver->setChecked(true);
|
ui->rbCANserver->setChecked(true);
|
||||||
break;
|
break;
|
||||||
|
case CANCon::CANLOGSERVER:
|
||||||
|
ui->rbCanlogserver->setChecked(true);
|
||||||
|
break;
|
||||||
default: {}
|
default: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,6 +342,7 @@ void NewConnectionDialog::setPortName(CANCon::type pType, QString pPortName, QSt
|
|||||||
ui->cbPort->setCurrentText(pPortName);
|
ui->cbPort->setCurrentText(pPortName);
|
||||||
break;
|
break;
|
||||||
case CANCon::CANSERVER:
|
case CANCon::CANSERVER:
|
||||||
|
case CANCon::CANLOGSERVER:
|
||||||
{
|
{
|
||||||
ui->cbPort->setCurrentText(pPortName);
|
ui->cbPort->setCurrentText(pPortName);
|
||||||
break;
|
break;
|
||||||
@@ -340,6 +363,7 @@ QString NewConnectionDialog::getPortName()
|
|||||||
case CANCon::KAYAK:
|
case CANCon::KAYAK:
|
||||||
return ui->cbPort->currentText();
|
return ui->cbPort->currentText();
|
||||||
case CANCon::CANSERVER:
|
case CANCon::CANSERVER:
|
||||||
|
case CANCon::CANLOGSERVER:
|
||||||
return ui->cbPort->currentText();
|
return ui->cbPort->currentText();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -385,6 +409,7 @@ CANCon::type NewConnectionDialog::getConnectionType()
|
|||||||
if (ui->rbMQTT->isChecked()) return CANCon::MQTT;
|
if (ui->rbMQTT->isChecked()) return CANCon::MQTT;
|
||||||
if (ui->rbLawicel->isChecked()) return CANCon::LAWICEL;
|
if (ui->rbLawicel->isChecked()) return CANCon::LAWICEL;
|
||||||
if (ui->rbCANserver->isChecked()) return CANCon::CANSERVER;
|
if (ui->rbCANserver->isChecked()) return CANCon::CANSERVER;
|
||||||
|
if (ui->rbCanlogserver->isChecked()) return CANCon::CANLOGSERVER;
|
||||||
qDebug() << "getConnectionType: error";
|
qDebug() << "getConnectionType: error";
|
||||||
|
|
||||||
return CANCon::NONE;
|
return CANCon::NONE;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ private:
|
|||||||
void selectMQTT();
|
void selectMQTT();
|
||||||
void selectLawicel();
|
void selectLawicel();
|
||||||
void selectCANserver();
|
void selectCANserver();
|
||||||
|
void selectCANlogserver();
|
||||||
bool isSerialBusAvailable();
|
bool isSerialBusAvailable();
|
||||||
void setPortName(CANCon::type pType, QString pPortName, QString pDriver);
|
void setPortName(CANCon::type pType, QString pPortName, QString pDriver);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ bool SerialBusConnection::piGetBusSettings(int pBusIdx, CANBus& pBus)
|
|||||||
|
|
||||||
void SerialBusConnection::piSetBusSettings(int pBusIdx, CANBus bus)
|
void SerialBusConnection::piSetBusSettings(int pBusIdx, CANBus bus)
|
||||||
{
|
{
|
||||||
|
quint32 sbusconfig = 0;
|
||||||
|
|
||||||
//CANConStatus stats;
|
//CANConStatus stats;
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
if(0 != pBusIdx)
|
if(0 != pBusIdx)
|
||||||
@@ -106,6 +108,10 @@ void SerialBusConnection::piSetBusSettings(int pBusIdx, CANBus bus)
|
|||||||
mDev_p->setConfigurationParameter(QCanBusDevice::BitRateKey, bus.speed);
|
mDev_p->setConfigurationParameter(QCanBusDevice::BitRateKey, bus.speed);
|
||||||
mDev_p->setConfigurationParameter(QCanBusDevice::CanFdKey, bus.canFD);
|
mDev_p->setConfigurationParameter(QCanBusDevice::CanFdKey, bus.canFD);
|
||||||
|
|
||||||
|
if(bus.listenOnly)
|
||||||
|
sbusconfig |= EN_SILENT_MODE;
|
||||||
|
mDev_p->setConfigurationParameter(QCanBusDevice::UserKey, sbusconfig);
|
||||||
|
|
||||||
/* connect device */
|
/* connect device */
|
||||||
if (!mDev_p->connectDevice()) {
|
if (!mDev_p->connectDevice()) {
|
||||||
disconnectDevice();
|
disconnectDevice();
|
||||||
|
|||||||
@@ -7,6 +7,21 @@
|
|||||||
#include <QCanBusDevice>
|
#include <QCanBusDevice>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
/*
|
||||||
|
QCanBusDevice::UserKey
|
||||||
|
0x00000001 - enable silent mode
|
||||||
|
0x00000002 - enable loopback mode
|
||||||
|
0x00000004 - disable auto retransmissions
|
||||||
|
0x00000008 - enable terminator
|
||||||
|
0x00000010 - enable automatic bus off recovery
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define EN_SILENT_MODE 0x00000001
|
||||||
|
#define EN_LOOPBACK_MODE 0x00000002
|
||||||
|
#define DIS_AUTO_RETRANSMISSIONS 0x00000004
|
||||||
|
#define EN_TERMINATOR 0x00000008
|
||||||
|
#define EN_AUTOMATIC_BUSOFF_RECOVERY 0x00000010
|
||||||
|
|
||||||
class SerialBusConnection : public CANConnection
|
class SerialBusConnection : public CANConnection
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -78,6 +78,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="7" column="0">
|
||||||
|
<widget class="QRadioButton" name="rbCanlogserver">
|
||||||
|
<property name="text">
|
||||||
|
<string>CANlogserver</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user