LAWICEL CAN-FD support, CAN-FD data rate selection
This commit is contained in:
@@ -21,7 +21,6 @@ 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 \
|
||||||
@@ -105,7 +104,6 @@ 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 \
|
||||||
|
|||||||
+12
-1
@@ -9,6 +9,7 @@ CANBus::CANBus()
|
|||||||
singleWire = false;
|
singleWire = false;
|
||||||
active = false;
|
active = false;
|
||||||
canFD = false;
|
canFD = false;
|
||||||
|
dataRate = 2000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -17,7 +18,8 @@ CANBus::CANBus(const CANBus& pBus) :
|
|||||||
listenOnly(pBus.listenOnly),
|
listenOnly(pBus.listenOnly),
|
||||||
singleWire(pBus.singleWire),
|
singleWire(pBus.singleWire),
|
||||||
active(pBus.active),
|
active(pBus.active),
|
||||||
canFD(pBus.canFD) {}
|
canFD(pBus.canFD),
|
||||||
|
dataRate(pBus.dataRate){}
|
||||||
|
|
||||||
|
|
||||||
bool CANBus::operator==(const CANBus& bus) const{
|
bool CANBus::operator==(const CANBus& bus) const{
|
||||||
@@ -57,6 +59,15 @@ int CANBus::getSpeed(){
|
|||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CANBus::getDataRate(){
|
||||||
|
return dataRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CANBus::setDataRate(int newSpeed){
|
||||||
|
//qDebug() << "CANBUS SetSpeed = " << newSpeed;
|
||||||
|
dataRate = newSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
bool CANBus::isListenOnly(){
|
bool CANBus::isListenOnly(){
|
||||||
return listenOnly;
|
return listenOnly;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public:
|
|||||||
bool singleWire;
|
bool singleWire;
|
||||||
bool active; //is this bus turned on?
|
bool active; //is this bus turned on?
|
||||||
bool canFD;
|
bool canFD;
|
||||||
|
int dataRate;
|
||||||
|
|
||||||
void setSpeed(int); // new speed
|
void setSpeed(int); // new speed
|
||||||
void setListenOnly(bool); //bool for whether to only listen
|
void setListenOnly(bool); //bool for whether to only listen
|
||||||
@@ -24,6 +25,8 @@ public:
|
|||||||
void setActive(bool); //whether this bus should be enabled or not.
|
void setActive(bool); //whether this bus should be enabled or not.
|
||||||
void setCanFD(bool); // enable or disable CANFD support
|
void setCanFD(bool); // enable or disable CANFD support
|
||||||
int getSpeed();
|
int getSpeed();
|
||||||
|
int getDataRate();
|
||||||
|
void setDataRate(int newSpeed);
|
||||||
bool isListenOnly();
|
bool isListenOnly();
|
||||||
bool isSingleWire();
|
bool isSingleWire();
|
||||||
bool isActive();
|
bool isActive();
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ namespace CANCon {
|
|||||||
MQTT,
|
MQTT,
|
||||||
LAWICEL,
|
LAWICEL,
|
||||||
CANSERVER,
|
CANSERVER,
|
||||||
CANLOGSERVER,
|
|
||||||
NONE
|
NONE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,10 @@
|
|||||||
#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;
|
||||||
|
|
||||||
CANConnection* CanConFactory::create(type pType, QString pPortName, QString pDriverName, int pSerialSpeed, int pBusSpeed)
|
CANConnection* CanConFactory::create(type pType, QString pPortName, QString pDriverName, int pSerialSpeed, int pBusSpeed, bool pCanFd, int pDataRate)
|
||||||
{
|
{
|
||||||
switch(pType) {
|
switch(pType) {
|
||||||
case SERIALBUS:
|
case SERIALBUS:
|
||||||
@@ -23,15 +22,13 @@ CANConnection* CanConFactory::create(type pType, QString pPortName, QString pDri
|
|||||||
case REMOTE:
|
case REMOTE:
|
||||||
return new GVRetSerial(pPortName, true); //it's a special case of GVRET connected over TCP/IP so it uses the same class
|
return new GVRetSerial(pPortName, true); //it's a special case of GVRET connected over TCP/IP so it uses the same class
|
||||||
case LAWICEL:
|
case LAWICEL:
|
||||||
return new LAWICELSerial(pPortName, pSerialSpeed, pBusSpeed);
|
return new LAWICELSerial(pPortName, pSerialSpeed, pBusSpeed, pCanFd, pDataRate);
|
||||||
case KAYAK:
|
case KAYAK:
|
||||||
return new SocketCANd(pPortName);
|
return new SocketCANd(pPortName);
|
||||||
case MQTT:
|
case MQTT:
|
||||||
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: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
class CanConFactory
|
class CanConFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CANConnection* create(CANCon::type, QString pPortName, QString pDriverName, int pSerialSpeed, int pBusSpeed);
|
static CANConnection* create(CANCon::type, QString pPortName, QString pDriverName, int pSerialSpeed, int pBusSpeed, bool pCanFd, int pDataRate);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CANCONFACTORY_H
|
#endif // CANCONFACTORY_H
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ CANConnection::CANConnection(QString pPort,
|
|||||||
CANCon::type pType,
|
CANCon::type pType,
|
||||||
int pSerialSpeed,
|
int pSerialSpeed,
|
||||||
int pBusSpeed,
|
int pBusSpeed,
|
||||||
|
bool pCanFd,
|
||||||
|
int pDataRate,
|
||||||
int pNumBuses,
|
int pNumBuses,
|
||||||
int pQueueLen,
|
int pQueueLen,
|
||||||
bool pUseThread) :
|
bool pUseThread) :
|
||||||
@@ -38,6 +40,8 @@ CANConnection::CANConnection(QString pPort,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pBusSpeed > 0) mBusData[0].mBus.setSpeed(pBusSpeed);
|
if (pBusSpeed > 0) mBusData[0].mBus.setSpeed(pBusSpeed);
|
||||||
|
mBusData[0].mBus.setCanFD(pCanFd);
|
||||||
|
if (pDataRate > 0) mBusData[0].mBus.setDataRate(pDataRate);
|
||||||
|
|
||||||
/* if needed, create a thread and move ourself into it */
|
/* if needed, create a thread and move ourself into it */
|
||||||
if(pUseThread) {
|
if(pUseThread) {
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ protected:
|
|||||||
CANCon::type pType,
|
CANCon::type pType,
|
||||||
int pSerialSpeed,
|
int pSerialSpeed,
|
||||||
int pBusSpeed,
|
int pBusSpeed,
|
||||||
|
bool pCanFd,
|
||||||
|
int pDataRate,
|
||||||
int pNumBuses,
|
int pNumBuses,
|
||||||
int pQueueLen,
|
int pQueueLen,
|
||||||
bool pUseThread);
|
bool pUseThread);
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ 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";
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "canserver.h"
|
#include "canserver.h"
|
||||||
|
|
||||||
CANserver::CANserver(QString serverAddressString) :
|
CANserver::CANserver(QString serverAddressString) :
|
||||||
CANConnection(serverAddressString, "CANserver", CANCon::CANSERVER, 0, 0, 3, 4000, true),
|
CANConnection(serverAddressString, "CANserver", CANCon::CANSERVER, 0, 0, false, 0, 3, 4000, true),
|
||||||
_udpClient(new QUdpSocket(this)),
|
_udpClient(new QUdpSocket(this)),
|
||||||
_heartbeatTimer(new QTimer(this))
|
_heartbeatTimer(new QTimer(this))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -253,6 +253,8 @@ void ConnectionWindow::handleNewConn()
|
|||||||
QString newDriver;
|
QString newDriver;
|
||||||
int newSerialSpeed;
|
int newSerialSpeed;
|
||||||
int newBusSpeed;
|
int newBusSpeed;
|
||||||
|
bool newCanFd;
|
||||||
|
int newDataRate;
|
||||||
CANConnection *conn;
|
CANConnection *conn;
|
||||||
|
|
||||||
if (thisDialog->exec() == QDialog::Accepted)
|
if (thisDialog->exec() == QDialog::Accepted)
|
||||||
@@ -262,7 +264,9 @@ void ConnectionWindow::handleNewConn()
|
|||||||
newDriver = thisDialog->getDriverName();
|
newDriver = thisDialog->getDriverName();
|
||||||
newSerialSpeed = thisDialog->getSerialSpeed();
|
newSerialSpeed = thisDialog->getSerialSpeed();
|
||||||
newBusSpeed = thisDialog->getBusSpeed();
|
newBusSpeed = thisDialog->getBusSpeed();
|
||||||
conn = create(newType, newPort, newDriver, newSerialSpeed, newBusSpeed);
|
newCanFd=thisDialog->isCanFd();
|
||||||
|
newDataRate = thisDialog->getDataRate();
|
||||||
|
conn = create(newType, newPort, newDriver, newSerialSpeed, newBusSpeed, newCanFd, newDataRate);
|
||||||
if (conn)
|
if (conn)
|
||||||
{
|
{
|
||||||
connModel->add(conn);
|
connModel->add(conn);
|
||||||
@@ -297,7 +301,8 @@ void ConnectionWindow::handleResetConn()
|
|||||||
{
|
{
|
||||||
QString port, driver;
|
QString port, driver;
|
||||||
CANCon::type type;
|
CANCon::type type;
|
||||||
int serSpeed, busSpeed;
|
int serSpeed, busSpeed, dataRate;
|
||||||
|
bool canFd;
|
||||||
|
|
||||||
int selIdx = ui->tableConnections->selectionModel()->currentIndex().row();
|
int selIdx = ui->tableConnections->selectionModel()->currentIndex().row();
|
||||||
if (selIdx <0) return;
|
if (selIdx <0) return;
|
||||||
@@ -312,13 +317,16 @@ void ConnectionWindow::handleResetConn()
|
|||||||
driver = conn_p->getDriver();
|
driver = conn_p->getDriver();
|
||||||
serSpeed = 0; //TODO: implement these
|
serSpeed = 0; //TODO: implement these
|
||||||
busSpeed = 0;
|
busSpeed = 0;
|
||||||
|
dataRate = 0;
|
||||||
|
canFd = false;
|
||||||
|
|
||||||
|
|
||||||
/* stop and delete connection */
|
/* stop and delete connection */
|
||||||
conn_p->stop();
|
conn_p->stop();
|
||||||
|
|
||||||
conn_p = nullptr;
|
conn_p = nullptr;
|
||||||
|
|
||||||
conn_p = create(type, port, driver, serSpeed, busSpeed);
|
conn_p = create(type, port, driver, serSpeed, busSpeed,canFd,dataRate);
|
||||||
if (conn_p) connModel->replace(selIdx, conn_p);
|
if (conn_p) connModel->replace(selIdx, conn_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,6 +374,7 @@ void ConnectionWindow::saveBusSettings()
|
|||||||
bus.setActive(ui->ckEnable->isChecked());
|
bus.setActive(ui->ckEnable->isChecked());
|
||||||
bus.setListenOnly(ui->ckListenOnly->isChecked());
|
bus.setListenOnly(ui->ckListenOnly->isChecked());
|
||||||
bus.setCanFD(ui->canFDEnable->isChecked());
|
bus.setCanFD(ui->canFDEnable->isChecked());
|
||||||
|
bus.setDataRate(ui->cbDataRate->currentText().toInt());
|
||||||
conn_p->setBusSettings(offset, bus);
|
conn_p->setBusSettings(offset, bus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -384,6 +393,8 @@ void ConnectionWindow::populateBusDetails(int offset)
|
|||||||
//int numBuses;
|
//int numBuses;
|
||||||
ui->canFDEnable->setVisible(false);
|
ui->canFDEnable->setVisible(false);
|
||||||
ui->canFDEnable_label->setVisible(false);
|
ui->canFDEnable_label->setVisible(false);
|
||||||
|
ui->dataRate_label->setVisible(false);
|
||||||
|
ui->cbDataRate->setVisible(false);
|
||||||
CANConnection* conn_p = connModel->getAtIdx(selIdx);
|
CANConnection* conn_p = connModel->getAtIdx(selIdx);
|
||||||
CANBus bus;
|
CANBus bus;
|
||||||
if(!conn_p) return;
|
if(!conn_p) return;
|
||||||
@@ -398,11 +409,13 @@ void ConnectionWindow::populateBusDetails(int offset)
|
|||||||
//ui->lblBusNum->setText(QString::number(busBase + offset));
|
//ui->lblBusNum->setText(QString::number(busBase + offset));
|
||||||
ui->ckListenOnly->setChecked(bus.isListenOnly());
|
ui->ckListenOnly->setChecked(bus.isListenOnly());
|
||||||
ui->ckEnable->setChecked(bus.isActive());
|
ui->ckEnable->setChecked(bus.isActive());
|
||||||
if (conn_p->getType() == CANCon::type::SERIALBUS)
|
if (conn_p->getType() == CANCon::type::SERIALBUS || conn_p->getType() == CANCon::type::LAWICEL)
|
||||||
{
|
{
|
||||||
ui->canFDEnable->setVisible(true);
|
ui->canFDEnable->setVisible(true);
|
||||||
ui->canFDEnable_label->setVisible(true);
|
ui->canFDEnable_label->setVisible(true);
|
||||||
ui->canFDEnable->setChecked(bus.isCanFD());
|
ui->canFDEnable->setChecked(bus.isCanFD());
|
||||||
|
ui->cbDataRate->setVisible(true);
|
||||||
|
ui->dataRate_label->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@@ -415,7 +428,19 @@ void ConnectionWindow::populateBusDetails(int offset)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) ui->cbBusSpeed->addItem(QString::number(bus.getSpeed()));
|
if (!found) ui->cbBusSpeed->addItem(QString::number(bus.getSpeed()));
|
||||||
|
found = false;
|
||||||
|
for (int i = 0; i < ui->cbDataRate->count(); i++)
|
||||||
|
{
|
||||||
|
if (bus.getDataRate() == ui->cbDataRate->itemText(i).toInt())
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
ui->cbDataRate->setCurrentIndex(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) ui->cbDataRate->addItem(QString::number(bus.getDataRate()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,12 +515,12 @@ void ConnectionWindow::handleSendText() {
|
|||||||
emit sendDebugData(bytes);
|
emit sendDebugData(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
CANConnection* ConnectionWindow::create(CANCon::type pTye, QString pPortName, QString pDriver, int pSerialSpeed, int pBusSpeed)
|
CANConnection* ConnectionWindow::create(CANCon::type pTye, QString pPortName, QString pDriver, int pSerialSpeed, int pBusSpeed, bool pCanFd, int pDataRate)
|
||||||
{
|
{
|
||||||
CANConnection* conn_p;
|
CANConnection* conn_p;
|
||||||
|
|
||||||
/* create connection */
|
/* create connection */
|
||||||
conn_p = CanConFactory::create(pTye, pPortName, pDriver, pSerialSpeed, pBusSpeed);
|
conn_p = CanConFactory::create(pTye, pPortName, pDriver, pSerialSpeed, pBusSpeed, pCanFd, pDataRate);
|
||||||
if(conn_p)
|
if(conn_p)
|
||||||
{
|
{
|
||||||
/* connect signal */
|
/* connect signal */
|
||||||
@@ -533,7 +558,7 @@ void ConnectionWindow::loadConnections()
|
|||||||
for(int i = 0 ; i < portNames.count() ; i++)
|
for(int i = 0 ; i < portNames.count() ; i++)
|
||||||
{
|
{
|
||||||
//TODO: add serial speed and bus speed to this properly.
|
//TODO: add serial speed and bus speed to this properly.
|
||||||
CANConnection* conn_p = create((CANCon::type)devTypes[i], portNames[i], driverNames[i], 0, 0);
|
CANConnection* conn_p = create((CANCon::type)devTypes[i], portNames[i], driverNames[i], 0, 0, false, 0);
|
||||||
/* add connection to model */
|
/* add connection to model */
|
||||||
connModel->add(conn_p);
|
connModel->add(conn_p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ private:
|
|||||||
QVector<QString> remoteDeviceIPGVRET;
|
QVector<QString> remoteDeviceIPGVRET;
|
||||||
QVector<QString> remoteDeviceKayak;
|
QVector<QString> remoteDeviceKayak;
|
||||||
|
|
||||||
CANConnection* create(CANCon::type pTye, QString pPortName, QString pDriver, int pSerialSpeed, int pBusSpeed);
|
CANConnection* create(CANCon::type pTye, QString pPortName, QString pDriver, int pSerialSpeed, int pBusSpeed, bool pCanFd, int pDataRate);
|
||||||
void populateBusDetails(int offset);
|
void populateBusDetails(int offset);
|
||||||
void loadConnections();
|
void loadConnections();
|
||||||
void saveConnections();
|
void saveConnections();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "gvretserial.h"
|
#include "gvretserial.h"
|
||||||
|
|
||||||
GVRetSerial::GVRetSerial(QString portName, bool useTcp) :
|
GVRetSerial::GVRetSerial(QString portName, bool useTcp) :
|
||||||
CANConnection(portName, "gvret", CANCon::GVRET_SERIAL, 0, 0, 3, 4000, true),
|
CANConnection(portName, "gvret", CANCon::GVRET_SERIAL, 0, 0, false, 0, 3, 4000, true),
|
||||||
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 */
|
||||||
useTcp(useTcp)
|
useTcp(useTcp)
|
||||||
{
|
{
|
||||||
|
|||||||
+207
-41
@@ -9,8 +9,8 @@
|
|||||||
#include "lawicel_serial.h"
|
#include "lawicel_serial.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
LAWICELSerial::LAWICELSerial(QString portName, int serialSpeed, int lawicelSpeed) :
|
LAWICELSerial::LAWICELSerial(QString portName, int serialSpeed, int lawicelSpeed, bool canFd, int dataRate) :
|
||||||
CANConnection(portName, "LAWICEL", CANCon::LAWICEL,serialSpeed, lawicelSpeed, 3, 4000, true),
|
CANConnection(portName, "LAWICEL", CANCon::LAWICEL,serialSpeed, lawicelSpeed, canFd, dataRate, 3, 4000, true),
|
||||||
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 */
|
||||||
{
|
{
|
||||||
sendDebug("LAWICELSerial()");
|
sendDebug("LAWICELSerial()");
|
||||||
@@ -154,13 +154,31 @@ bool LAWICELSerial::piSendFrame(const CANFrame& frame)
|
|||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
QString buildStr;
|
QString buildStr;
|
||||||
if (frame.hasExtendedFrameFormat())
|
if(frame.hasFlexibleDataRateFormat()){
|
||||||
{
|
if (frame.hasExtendedFrameFormat())
|
||||||
buildStr = QString::asprintf("T%08X%u", ID, frame.payload().length());
|
{
|
||||||
|
if (frame.hasBitrateSwitch())
|
||||||
|
buildStr = QString::asprintf("B%08X%u", ID, LAWICELSerial::bytes_to_dlc_code(frame.payload().length()));
|
||||||
|
else
|
||||||
|
buildStr = QString::asprintf("D%08X%u", ID, LAWICELSerial::bytes_to_dlc_code(frame.payload().length()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (frame.hasBitrateSwitch())
|
||||||
|
buildStr = QString::asprintf("b%03X%u", ID, LAWICELSerial::bytes_to_dlc_code(frame.payload().length()));
|
||||||
|
else
|
||||||
|
buildStr = QString::asprintf("d%03X%u", ID, LAWICELSerial::bytes_to_dlc_code(frame.payload().length()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (frame.hasExtendedFrameFormat())
|
||||||
buildStr = QString::asprintf("t%03X%u", ID, frame.payload().length());
|
{
|
||||||
|
buildStr = QString::asprintf("T%08X%u", ID, frame.payload().length());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buildStr = QString::asprintf("t%03X%u", ID, frame.payload().length());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach (QChar chr, buildStr)
|
foreach (QChar chr, buildStr)
|
||||||
{
|
{
|
||||||
@@ -245,44 +263,71 @@ void LAWICELSerial::deviceConnected()
|
|||||||
|
|
||||||
output.clear();
|
output.clear();
|
||||||
output.append('S'); //configure speed of bus
|
output.append('S'); //configure speed of bus
|
||||||
switch (this->mBusData[0].mBus.getSpeed())
|
switch (this->mBusData[0].mBus.getSpeed())
|
||||||
{
|
{
|
||||||
case 10000:
|
case 10000:
|
||||||
output.append('0');
|
output.append('0');
|
||||||
break;
|
break;
|
||||||
case 20000:
|
case 20000:
|
||||||
output.append('1');
|
output.append('1');
|
||||||
break;
|
break;
|
||||||
case 50000:
|
case 50000:
|
||||||
output.append('2');
|
output.append('2');
|
||||||
break;
|
break;
|
||||||
case 100000:
|
case 100000:
|
||||||
output.append('3');
|
output.append('3');
|
||||||
break;
|
break;
|
||||||
case 125000:
|
case 125000:
|
||||||
output.append('4');
|
output.append('4');
|
||||||
break;
|
break;
|
||||||
case 250000:
|
case 250000:
|
||||||
output.append('5');
|
output.append('5');
|
||||||
break;
|
break;
|
||||||
case 500000:
|
case 500000:
|
||||||
output.append('6');
|
output.append('6');
|
||||||
break;
|
break;
|
||||||
case 800000:
|
case 800000:
|
||||||
output.append('7');
|
output.append('7');
|
||||||
break;
|
break;
|
||||||
case 1000000:
|
case 1000000:
|
||||||
output.append('8');
|
output.append('8');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
output.append('6');
|
output.append('6');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.append('\x0D');
|
output.append('\x0D');
|
||||||
|
|
||||||
sendToSerial(output);
|
sendToSerial(output);
|
||||||
|
|
||||||
output.clear();
|
output.clear();
|
||||||
|
|
||||||
|
if (this->canFd){
|
||||||
|
switch (this->dataRate)
|
||||||
|
{
|
||||||
|
case 1000000:
|
||||||
|
output.append("Y1");
|
||||||
|
break;
|
||||||
|
case 2000000:
|
||||||
|
output.append("Y2");
|
||||||
|
break;
|
||||||
|
case 4000000:
|
||||||
|
output.append("Y4");
|
||||||
|
break;
|
||||||
|
case 5000000:
|
||||||
|
output.append("Y5");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
output.append("Y2");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
output.append('\x0D');
|
||||||
|
sendToSerial(output);
|
||||||
|
output.clear();
|
||||||
|
}
|
||||||
|
|
||||||
output.append('O'); //open bus now that we set the speed
|
output.append('O'); //open bus now that we set the speed
|
||||||
output.append(13);
|
output.append(13);
|
||||||
|
|
||||||
@@ -445,6 +490,8 @@ void LAWICELSerial::readSerialData()
|
|||||||
if (c == 13) //all lawicel commands end in CR
|
if (c == 13) //all lawicel commands end in CR
|
||||||
{
|
{
|
||||||
qDebug() << "Got CR!";
|
qDebug() << "Got CR!";
|
||||||
|
|
||||||
|
buildFrame.setTimeStamp(QDateTime::currentMSecsSinceEpoch() * 1000l);
|
||||||
switch (mBuildLine[0].toLatin1())
|
switch (mBuildLine[0].toLatin1())
|
||||||
{
|
{
|
||||||
case 't': //standard frame
|
case 't': //standard frame
|
||||||
@@ -502,6 +549,68 @@ void LAWICELSerial::readSerialData()
|
|||||||
qDebug() << "can't get a frame, ERROR";
|
qDebug() << "can't get a frame, ERROR";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'b':
|
||||||
|
buildFrame.setBitrateSwitch(true); //BRS enabled
|
||||||
|
case 'd': //standard fd frame, BRS disabled
|
||||||
|
//tIIILDD
|
||||||
|
buildFrame.setFlexibleDataRateFormat(true);
|
||||||
|
buildFrame.setFrameId(mBuildLine.mid(1, 3).toInt(nullptr, 16));
|
||||||
|
buildFrame.isReceived = true;
|
||||||
|
buildFrame.setFrameType(QCanBusFrame::FrameType::DataFrame);
|
||||||
|
buildData.resize(LAWICELSerial::dlc_code_to_bytes(mBuildLine.mid(4, 1).toInt(nullptr, 16)));
|
||||||
|
for (int c = 0; c < buildData.size(); c++)
|
||||||
|
{
|
||||||
|
buildData[c] = mBuildLine.mid(5 + (c*2), 2).toInt(nullptr, 16);
|
||||||
|
}
|
||||||
|
buildFrame.setPayload(buildData);
|
||||||
|
if (!isCapSuspended())
|
||||||
|
{
|
||||||
|
/* get frame from queue */
|
||||||
|
CANFrame* frame_p = getQueue().get();
|
||||||
|
if(frame_p) {
|
||||||
|
//qDebug() << "Lawicel got frame on bus " << frame_p->bus;
|
||||||
|
/* copy frame */
|
||||||
|
*frame_p = buildFrame;
|
||||||
|
checkTargettedFrame(buildFrame);
|
||||||
|
/* enqueue frame */
|
||||||
|
getQueue().queue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
qDebug() << "can't get a frame, ERROR";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
buildFrame.setBitrateSwitch(true); //BRS enabled
|
||||||
|
case 'D': //extended fd frame
|
||||||
|
//TIIIIIIIILDD.
|
||||||
|
buildFrame.setFlexibleDataRateFormat(true);
|
||||||
|
buildFrame.setBitrateSwitch(true);
|
||||||
|
buildFrame.setFrameId(mBuildLine.mid(1, 8).toInt(nullptr, 16));
|
||||||
|
buildFrame.isReceived = true;
|
||||||
|
buildFrame.setFrameType(QCanBusFrame::FrameType::DataFrame);
|
||||||
|
buildFrame.setExtendedFrameFormat(true);
|
||||||
|
buildData.resize(LAWICELSerial::dlc_code_to_bytes(mBuildLine.mid(4, 1).toInt(nullptr, 16)));
|
||||||
|
for (int c = 0; c < buildData.size(); c++)
|
||||||
|
{
|
||||||
|
buildData[c] = mBuildLine.mid(10 + (c*2), 2).toInt(nullptr, 16);
|
||||||
|
}
|
||||||
|
buildFrame.setPayload(buildData);
|
||||||
|
if (!isCapSuspended())
|
||||||
|
{
|
||||||
|
/* get frame from queue */
|
||||||
|
CANFrame* frame_p = getQueue().get();
|
||||||
|
if(frame_p) {
|
||||||
|
//qDebug() << "Lawicel got frame on bus " << frame_p->bus;
|
||||||
|
/* copy frame */
|
||||||
|
*frame_p = buildFrame;
|
||||||
|
checkTargettedFrame(buildFrame);
|
||||||
|
/* enqueue frame */
|
||||||
|
getQueue().queue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
qDebug() << "can't get a frame, ERROR";
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
mBuildLine.clear();
|
mBuildLine.clear();
|
||||||
}
|
}
|
||||||
@@ -520,3 +629,60 @@ void LAWICELSerial::handleTick()
|
|||||||
//qDebug() << "Tick!";
|
//qDebug() << "Tick!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Convert a FDCAN_data_length_code to number of bytes in a message
|
||||||
|
uint8_t LAWICELSerial::dlc_code_to_bytes(int dlc_code)
|
||||||
|
{
|
||||||
|
if (dlc_code<=8)
|
||||||
|
return dlc_code;
|
||||||
|
else{
|
||||||
|
switch(dlc_code)
|
||||||
|
{
|
||||||
|
case 9:
|
||||||
|
return 12;
|
||||||
|
case 10:
|
||||||
|
return 16;
|
||||||
|
case 11:
|
||||||
|
return 20;
|
||||||
|
case 12:
|
||||||
|
return 24;
|
||||||
|
case 13:
|
||||||
|
return 32;
|
||||||
|
case 14:
|
||||||
|
return 48;
|
||||||
|
case 15:
|
||||||
|
return 64;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t LAWICELSerial::bytes_to_dlc_code(uint8_t bytes)
|
||||||
|
{
|
||||||
|
if (bytes<=8)
|
||||||
|
return bytes;
|
||||||
|
else{
|
||||||
|
switch(bytes)
|
||||||
|
{
|
||||||
|
case 12:
|
||||||
|
return 9;
|
||||||
|
case 16:
|
||||||
|
return 10;
|
||||||
|
case 20:
|
||||||
|
return 11;
|
||||||
|
case 24:
|
||||||
|
return 12;
|
||||||
|
case 32:
|
||||||
|
return 13;
|
||||||
|
case 48:
|
||||||
|
return 14;
|
||||||
|
case 64:
|
||||||
|
return 15;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class LAWICELSerial : public CANConnection
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LAWICELSerial(QString portName, int serialSpeed, int lawicelSpeed);
|
LAWICELSerial(QString portName, int serialSpeed, int lawicelSpeed, bool canFd, int dataRate);
|
||||||
virtual ~LAWICELSerial();
|
virtual ~LAWICELSerial();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -49,6 +49,8 @@ private:
|
|||||||
void rebuildLocalTimeBasis();
|
void rebuildLocalTimeBasis();
|
||||||
void sendToSerial(const QByteArray &bytes);
|
void sendToSerial(const QByteArray &bytes);
|
||||||
void sendDebug(const QString debugText);
|
void sendDebug(const QString debugText);
|
||||||
|
uint8_t dlc_code_to_bytes(int dlc_code);
|
||||||
|
uint8_t bytes_to_dlc_code(uint8_t bytes);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QTimer mTimer;
|
QTimer mTimer;
|
||||||
@@ -61,6 +63,8 @@ protected:
|
|||||||
CANFrame buildFrame;
|
CANFrame buildFrame;
|
||||||
bool can0Enabled;
|
bool can0Enabled;
|
||||||
bool can0ListenOnly;
|
bool can0ListenOnly;
|
||||||
|
bool canFd;
|
||||||
|
int dataRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAWICELSERIAL_H
|
#endif // LAWICELSERIAL_H
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "mqtt_bus.h"
|
#include "mqtt_bus.h"
|
||||||
|
|
||||||
MQTT_BUS::MQTT_BUS(QString topicName) :
|
MQTT_BUS::MQTT_BUS(QString topicName) :
|
||||||
CANConnection(topicName, "mqtt_client", CANCon::MQTT, 0, 0, 1, 4000, true),
|
CANConnection(topicName, "mqtt_client", CANCon::MQTT, 0, 0, false, 0, 1, 4000, true),
|
||||||
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 */
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ 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);
|
||||||
@@ -40,6 +39,10 @@ NewConnectionDialog::NewConnectionDialog(QVector<QString>* gvretips, QVector<QSt
|
|||||||
ui->cbSerialSpeed->setHidden(true);
|
ui->cbSerialSpeed->setHidden(true);
|
||||||
ui->lblCANSpeed->setHidden(true);
|
ui->lblCANSpeed->setHidden(true);
|
||||||
ui->lblSerialSpeed->setHidden(true);
|
ui->lblSerialSpeed->setHidden(true);
|
||||||
|
ui->cbCanFd->setHidden(true);
|
||||||
|
ui->cbDataRate->setHidden(true);
|
||||||
|
ui->lblDataRate->setHidden(true);
|
||||||
|
|
||||||
selectSerial();
|
selectSerial();
|
||||||
|
|
||||||
qDebug() << "Was passed " << remoteDeviceIPGVRET->count() << " remote GVRET IPs";
|
qDebug() << "Was passed " << remoteDeviceIPGVRET->count() << " remote GVRET IPs";
|
||||||
@@ -65,7 +68,6 @@ 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()
|
||||||
@@ -89,6 +91,9 @@ void NewConnectionDialog::selectLawicel()
|
|||||||
ui->cbSerialSpeed->setHidden(false);
|
ui->cbSerialSpeed->setHidden(false);
|
||||||
ui->lblCANSpeed->setHidden(false);
|
ui->lblCANSpeed->setHidden(false);
|
||||||
ui->lblSerialSpeed->setHidden(false);
|
ui->lblSerialSpeed->setHidden(false);
|
||||||
|
ui->cbCanFd->setHidden(false);
|
||||||
|
ui->cbDataRate->setHidden(false);
|
||||||
|
ui->lblDataRate->setHidden(false);
|
||||||
|
|
||||||
ui->cbPort->clear();
|
ui->cbPort->clear();
|
||||||
ports = QSerialPortInfo::availablePorts();
|
ports = QSerialPortInfo::availablePorts();
|
||||||
@@ -108,6 +113,13 @@ void NewConnectionDialog::selectLawicel()
|
|||||||
ui->cbCANSpeed->addItem("500000");
|
ui->cbCANSpeed->addItem("500000");
|
||||||
ui->cbCANSpeed->addItem("1000000");
|
ui->cbCANSpeed->addItem("1000000");
|
||||||
}
|
}
|
||||||
|
if (ui->cbDataRate->count() == 0)
|
||||||
|
{
|
||||||
|
ui->cbDataRate->addItem("1000000");
|
||||||
|
ui->cbDataRate->addItem("2000000");
|
||||||
|
ui->cbDataRate->addItem("4000000");
|
||||||
|
ui->cbDataRate->addItem("5000000");
|
||||||
|
}
|
||||||
if (ui->cbSerialSpeed->count() == 0)
|
if (ui->cbSerialSpeed->count() == 0)
|
||||||
{
|
{
|
||||||
ui->cbSerialSpeed->addItem("115200");
|
ui->cbSerialSpeed->addItem("115200");
|
||||||
@@ -130,6 +142,9 @@ void NewConnectionDialog::selectSerial()
|
|||||||
ui->cbSerialSpeed->setHidden(true);
|
ui->cbSerialSpeed->setHidden(true);
|
||||||
ui->lblCANSpeed->setHidden(true);
|
ui->lblCANSpeed->setHidden(true);
|
||||||
ui->lblSerialSpeed->setHidden(true);
|
ui->lblSerialSpeed->setHidden(true);
|
||||||
|
ui->cbCanFd->setHidden(true);
|
||||||
|
ui->cbDataRate->setHidden(true);
|
||||||
|
ui->lblDataRate->setHidden(true);
|
||||||
|
|
||||||
ui->cbPort->clear();
|
ui->cbPort->clear();
|
||||||
ports = QSerialPortInfo::availablePorts();
|
ports = QSerialPortInfo::availablePorts();
|
||||||
@@ -147,6 +162,9 @@ void NewConnectionDialog::selectSocketCan()
|
|||||||
ui->cbSerialSpeed->setHidden(true);
|
ui->cbSerialSpeed->setHidden(true);
|
||||||
ui->lblCANSpeed->setHidden(true);
|
ui->lblCANSpeed->setHidden(true);
|
||||||
ui->lblSerialSpeed->setHidden(true);
|
ui->lblSerialSpeed->setHidden(true);
|
||||||
|
ui->cbCanFd->setHidden(true);
|
||||||
|
ui->cbDataRate->setHidden(true);
|
||||||
|
ui->lblDataRate->setHidden(true);
|
||||||
|
|
||||||
ui->cbDeviceType->clear();
|
ui->cbDeviceType->clear();
|
||||||
QStringList plugins;
|
QStringList plugins;
|
||||||
@@ -166,6 +184,9 @@ void NewConnectionDialog::selectRemote()
|
|||||||
ui->cbSerialSpeed->setHidden(true);
|
ui->cbSerialSpeed->setHidden(true);
|
||||||
ui->lblCANSpeed->setHidden(true);
|
ui->lblCANSpeed->setHidden(true);
|
||||||
ui->lblSerialSpeed->setHidden(true);
|
ui->lblSerialSpeed->setHidden(true);
|
||||||
|
ui->cbCanFd->setHidden(true);
|
||||||
|
ui->cbDataRate->setHidden(true);
|
||||||
|
ui->lblDataRate->setHidden(true);
|
||||||
|
|
||||||
ui->cbPort->clear();
|
ui->cbPort->clear();
|
||||||
foreach(QString pName, *remoteDeviceIPGVRET)
|
foreach(QString pName, *remoteDeviceIPGVRET)
|
||||||
@@ -184,6 +205,9 @@ void NewConnectionDialog::selectKayak()
|
|||||||
ui->cbSerialSpeed->setHidden(true);
|
ui->cbSerialSpeed->setHidden(true);
|
||||||
ui->lblCANSpeed->setHidden(true);
|
ui->lblCANSpeed->setHidden(true);
|
||||||
ui->lblSerialSpeed->setHidden(true);
|
ui->lblSerialSpeed->setHidden(true);
|
||||||
|
ui->cbCanFd->setHidden(true);
|
||||||
|
ui->cbDataRate->setHidden(true);
|
||||||
|
ui->lblDataRate->setHidden(true);
|
||||||
|
|
||||||
ui->cbPort->clear();
|
ui->cbPort->clear();
|
||||||
foreach(QString pName, *remoteBusKayak)
|
foreach(QString pName, *remoteBusKayak)
|
||||||
@@ -202,6 +226,9 @@ void NewConnectionDialog::selectMQTT()
|
|||||||
ui->cbSerialSpeed->setHidden(true);
|
ui->cbSerialSpeed->setHidden(true);
|
||||||
ui->lblCANSpeed->setHidden(true);
|
ui->lblCANSpeed->setHidden(true);
|
||||||
ui->lblSerialSpeed->setHidden(true);
|
ui->lblSerialSpeed->setHidden(true);
|
||||||
|
ui->cbCanFd->setHidden(true);
|
||||||
|
ui->cbDataRate->setHidden(true);
|
||||||
|
ui->lblDataRate->setHidden(true);
|
||||||
|
|
||||||
ui->cbPort->clear();
|
ui->cbPort->clear();
|
||||||
}
|
}
|
||||||
@@ -216,20 +243,9 @@ void NewConnectionDialog::selectCANserver()
|
|||||||
ui->cbSerialSpeed->setHidden(true);
|
ui->cbSerialSpeed->setHidden(true);
|
||||||
ui->lblCANSpeed->setHidden(true);
|
ui->lblCANSpeed->setHidden(true);
|
||||||
ui->lblSerialSpeed->setHidden(true);
|
ui->lblSerialSpeed->setHidden(true);
|
||||||
|
ui->cbCanFd->setHidden(true);
|
||||||
ui->cbPort->clear();
|
ui->cbDataRate->setHidden(true);
|
||||||
}
|
ui->lblDataRate->setHidden(true);
|
||||||
|
|
||||||
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->cbPort->clear();
|
ui->cbPort->clear();
|
||||||
}
|
}
|
||||||
@@ -260,9 +276,6 @@ 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: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +320,6 @@ 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;
|
||||||
@@ -328,7 +340,6 @@ 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:
|
||||||
@@ -374,7 +385,6 @@ 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;
|
||||||
@@ -385,3 +395,21 @@ bool NewConnectionDialog::isSerialBusAvailable()
|
|||||||
if (QCanBus::instance()->plugins().count() > 0) return true;
|
if (QCanBus::instance()->plugins().count() > 0) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int NewConnectionDialog::getDataRate()
|
||||||
|
{
|
||||||
|
if (getConnectionType() == CANCon::LAWICEL)
|
||||||
|
{
|
||||||
|
return ui->cbDataRate->currentText().toInt();
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NewConnectionDialog::isCanFd()
|
||||||
|
{
|
||||||
|
if (getConnectionType() == CANCon::LAWICEL)
|
||||||
|
{
|
||||||
|
return ui->cbCanFd;
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public:
|
|||||||
QString getDriverName();
|
QString getDriverName();
|
||||||
int getSerialSpeed();
|
int getSerialSpeed();
|
||||||
int getBusSpeed();
|
int getBusSpeed();
|
||||||
|
bool isCanFd();
|
||||||
|
int getDataRate();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleConnTypeChanged();
|
void handleConnTypeChanged();
|
||||||
@@ -47,7 +49,6 @@ 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);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
/***********************************/
|
/***********************************/
|
||||||
|
|
||||||
SerialBusConnection::SerialBusConnection(QString portName, QString driverName) :
|
SerialBusConnection::SerialBusConnection(QString portName, QString driverName) :
|
||||||
CANConnection(portName, driverName, CANCon::SERIALBUS,0 ,0 ,1, 4000, true),
|
CANConnection(portName, driverName, CANCon::SERIALBUS,0 ,0, false, 0 ,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 */
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -78,8 +78,6 @@ 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)
|
||||||
@@ -108,10 +106,6 @@ 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,21 +7,6 @@
|
|||||||
#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
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "socketcand.h"
|
#include "socketcand.h"
|
||||||
|
|
||||||
SocketCANd::SocketCANd(QString portName) :
|
SocketCANd::SocketCANd(QString portName) :
|
||||||
CANConnection(portName, "kayak", CANCon::KAYAK, 0, 0, 1, 4000, true),
|
CANConnection(portName, "kayak", CANCon::KAYAK, 0, 0, false, 0, 1, 4000, true),
|
||||||
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
-1
@@ -104,7 +104,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QPushButton" name="btnSaveBus">
|
<widget class="QPushButton" name="btnSaveBus">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save Bus Settings</string>
|
<string>Save Bus Settings</string>
|
||||||
@@ -121,6 +121,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QComboBox" name="cbDataRate"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="dataRate_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>CAN FD Data Rate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@@ -78,13 +78,6 @@
|
|||||||
</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>
|
||||||
@@ -150,6 +143,23 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="cbCANSpeed"/>
|
<widget class="QComboBox" name="cbCANSpeed"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cbCanFd">
|
||||||
|
<property name="text">
|
||||||
|
<string>CAN-FD</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblDataRate">
|
||||||
|
<property name="text">
|
||||||
|
<string>CAN-FD data rate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="cbDataRate"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
Reference in New Issue
Block a user