Add a new connection type - Lawicel. It works for some devices, not

all. More development needed but this is a start. Also added ability
to set serial speed and bus speed in the device setup which may be
useful for other connection devices too.
This commit is contained in:
Collin Kidder
2022-10-04 19:48:11 -04:00
parent 2afd41b681
commit 9ebbaca668
18 changed files with 763 additions and 35 deletions
+96
View File
@@ -27,12 +27,17 @@ NewConnectionDialog::NewConnectionDialog(QVector<QString>* gvretips, QVector<QSt
connect(ui->rbRemote, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
connect(ui->rbKayak, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
connect(ui->rbMQTT, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
connect(ui->rbLawicel, &QAbstractButton::clicked, this, &NewConnectionDialog::handleConnTypeChanged);
connect(ui->cbDeviceType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &NewConnectionDialog::handleDeviceTypeChanged);
connect(ui->btnOK, &QPushButton::clicked, this, &NewConnectionDialog::handleCreateButton);
ui->lblDeviceType->setHidden(true);
ui->cbDeviceType->setHidden(true);
ui->cbCANSpeed->setHidden(true);
ui->cbSerialSpeed->setHidden(true);
ui->lblCANSpeed->setHidden(true);
ui->lblSerialSpeed->setHidden(true);
selectSerial();
qDebug() << "Was passed " << remoteDeviceIPGVRET->count() << " remote GVRET IPs";
@@ -53,6 +58,7 @@ void NewConnectionDialog::handleConnTypeChanged()
{
if (ui->rbGVRET->isChecked()) selectSerial();
if (ui->rbSocketCAN->isChecked()) selectSocketCan();
if (ui->rbLawicel->isChecked()) selectLawicel();
if (ui->rbRemote->isChecked()) selectRemote();
if (ui->rbKayak->isChecked()) selectKayak();
if (ui->rbMQTT->isChecked()) selectMQTT();
@@ -68,12 +74,57 @@ void NewConnectionDialog::handleDeviceTypeChanged()
ui->cbPort->addItem(canDevices[i].name());
}
void NewConnectionDialog::selectLawicel()
{
ui->lPort->setText("Serial Port:");
ui->lblDeviceType->setHidden(true);
ui->cbDeviceType->setHidden(true);
ui->cbCANSpeed->setHidden(false);
ui->cbSerialSpeed->setHidden(false);
ui->lblCANSpeed->setHidden(false);
ui->lblSerialSpeed->setHidden(false);
ui->cbPort->clear();
ports = QSerialPortInfo::availablePorts();
for (int i = 0; i < ports.count(); i++)
ui->cbPort->addItem(ports[i].portName());
if (ui->cbCANSpeed->count() == 0)
{
ui->cbCANSpeed->addItem("10000");
ui->cbCANSpeed->addItem("20000");
ui->cbCANSpeed->addItem("50000");
ui->cbCANSpeed->addItem("100000");
ui->cbCANSpeed->addItem("125000");
ui->cbCANSpeed->addItem("250000");
ui->cbCANSpeed->addItem("500000");
ui->cbCANSpeed->addItem("1000000");
}
if (ui->cbSerialSpeed->count() == 0)
{
ui->cbSerialSpeed->addItem("115200");
ui->cbSerialSpeed->addItem("150000");
ui->cbSerialSpeed->addItem("250000");
ui->cbSerialSpeed->addItem("500000");
ui->cbSerialSpeed->addItem("1000000");
ui->cbSerialSpeed->addItem("2000000");
}
}
void NewConnectionDialog::selectSerial()
{
ui->lPort->setText("Serial Port:");
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();
ports = QSerialPortInfo::availablePorts();
@@ -87,6 +138,10 @@ void NewConnectionDialog::selectSocketCan()
ui->lPort->setText("Port:");
ui->lblDeviceType->setHidden(false);
ui->cbDeviceType->setHidden(false);
ui->cbCANSpeed->setHidden(true);
ui->cbSerialSpeed->setHidden(true);
ui->lblCANSpeed->setHidden(true);
ui->lblSerialSpeed->setHidden(true);
ui->cbDeviceType->clear();
QStringList plugins;
@@ -99,8 +154,14 @@ void NewConnectionDialog::selectSocketCan()
void NewConnectionDialog::selectRemote()
{
ui->lPort->setText("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();
foreach(QString pName, *remoteDeviceIPGVRET)
{
@@ -111,8 +172,14 @@ void NewConnectionDialog::selectRemote()
void NewConnectionDialog::selectKayak()
{
ui->lPort->setText("Available Bus(ses):");
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();
foreach(QString pName, *remoteBusKayak)
{
@@ -123,8 +190,14 @@ void NewConnectionDialog::selectKayak()
void NewConnectionDialog::selectMQTT()
{
ui->lPort->setText("Topic Name:");
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();
}
@@ -148,6 +221,8 @@ void NewConnectionDialog::setPortName(CANCon::type pType, QString pPortName, QSt
case CANCon::MQTT:
ui->rbMQTT->setChecked(true);
break;
case CANCon::LAWICEL:
ui->rbLawicel->setChecked(true);
default: {}
}
@@ -157,6 +232,7 @@ void NewConnectionDialog::setPortName(CANCon::type pType, QString pPortName, QSt
switch(pType)
{
case CANCon::GVRET_SERIAL:
case CANCon::LAWICEL:
{
int idx = ui->cbPort->findText(pPortName);
if( idx<0 ) idx=0;
@@ -201,6 +277,7 @@ QString NewConnectionDialog::getPortName()
case CANCon::SERIALBUS:
case CANCon::REMOTE:
case CANCon::MQTT:
case CANCon::LAWICEL:
return ui->cbPort->currentText();
case CANCon::KAYAK:
return ui->cbPort->currentText();
@@ -220,6 +297,24 @@ QString NewConnectionDialog::getDriverName()
return "N/A";
}
int NewConnectionDialog::getSerialSpeed()
{
if (getConnectionType() == CANCon::LAWICEL)
{
return ui->cbSerialSpeed->currentText().toInt();
}
else return 0;
}
int NewConnectionDialog::getBusSpeed()
{
if (getConnectionType() == CANCon::LAWICEL)
{
return ui->cbCANSpeed->currentText().toInt();
}
else return 0;
}
CANCon::type NewConnectionDialog::getConnectionType()
{
if (ui->rbGVRET->isChecked()) return CANCon::GVRET_SERIAL;
@@ -227,6 +322,7 @@ CANCon::type NewConnectionDialog::getConnectionType()
if (ui->rbRemote->isChecked()) return CANCon::REMOTE;
if (ui->rbKayak->isChecked()) return CANCon::KAYAK;
if (ui->rbMQTT->isChecked()) return CANCon::MQTT;
if (ui->rbLawicel->isChecked()) return CANCon::LAWICEL;
qDebug() << "getConnectionType: error";
return CANCon::NONE;