From bc4e823d3d244032098cc41861f98041e3b20b99 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Mon, 23 Oct 2017 19:45:08 -0400 Subject: [PATCH] CAN Connection Window mostly done now. --- connections/canbus.cpp | 5 +++++ connections/connectionwindow.cpp | 30 ------------------------------ connections/gvretserial.cpp | 9 +++++++-- connections/socketcan.cpp | 1 + 4 files changed, 13 insertions(+), 32 deletions(-) diff --git a/connections/canbus.cpp b/connections/canbus.cpp index d0f4646..13aeb11 100644 --- a/connections/canbus.cpp +++ b/connections/canbus.cpp @@ -1,4 +1,5 @@ #include +#include #include "canbus.h" CANBus::CANBus() @@ -25,18 +26,22 @@ bool CANBus::operator==(const CANBus& bus) const{ } void CANBus::setSpeed(int newSpeed){ + //qDebug() << "CANBUS SetSpeed = " << newSpeed; speed = newSpeed; } void CANBus::setListenOnly(bool mode){ + //qDebug() << "CANBUS SetListenOnly = " << mode; listenOnly = mode; } void CANBus::setSingleWire(bool mode){ + //qDebug() << "CANBUS SetSingleWire = " << mode; singleWire = mode; } void CANBus::setEnabled(bool mode){ + //qDebug() << "CANBUS SetEnabled = " << mode; active = mode; } diff --git a/connections/connectionwindow.cpp b/connections/connectionwindow.cpp index 3289906..a326a9e 100644 --- a/connections/connectionwindow.cpp +++ b/connections/connectionwindow.cpp @@ -216,20 +216,6 @@ void ConnectionWindow::handleOKButton() conn_p = create(getConnectionType(), getPortName()); if(!conn_p) return; - - for (int i=0 ; igetNumBuses() ; i++) { - /* set bus configuration */ - CANBus bus; - //bus.active = ui->ckEnabled->isChecked(); - //bus.listenOnly = ui->ckListenOnly->isChecked(); - //bus.singleWire = ui->ckSingleWire->isChecked(); - - //bus.speed = ui->cbSpeed->currentText().toInt(); - - /* update bus settings */ - conn_p->setBusSettings(i, bus); - } - /* add connection to model */ connModel->add(conn_p); } @@ -480,17 +466,10 @@ void ConnectionWindow::loadConnections() /* fill connection list */ QVector portNames = settings.value("connections/portNames").value>(); QVector devTypes = settings.value("connections/types").value>(); - QList busses = settings.value("connections/busses").value>(); - for(int i=0 ; igetNumBuses() ; j++) - conn_p->setBusSettings(j, busses.takeFirst()); - } /* add connection to model */ connModel->add(conn_p); } @@ -507,23 +486,14 @@ void ConnectionWindow::saveConnections() QSettings settings; QVector portNames; QVector devTypes; - QList busses; /* save connections */ foreach(CANConnection* conn_p, conns) { portNames.append(conn_p->getPort()); devTypes.append(conn_p->getType()); - - for(int i=0 ; igetNumBuses() ; i++) - { - CANBus bus; - conn_p->getBusSettings(i, bus); - busses.append(bus); - } } settings.setValue("connections/portNames", QVariant::fromValue(portNames)); settings.setValue("connections/types", QVariant::fromValue(devTypes)); - settings.setValue("connections/busses", QVariant::fromValue(busses)); } diff --git a/connections/gvretserial.cpp b/connections/gvretserial.cpp index 62b6f78..0e38871 100644 --- a/connections/gvretserial.cpp +++ b/connections/gvretserial.cpp @@ -148,8 +148,8 @@ void GVRetSerial::piSetBusSettings(int pBusIdx, CANBus bus) if (pBusIdx < 2) { /* update baud rates */ QByteArray buffer; - qDebug() << "Got signal to update bauds. 1: " << can0Baud <<" 2: " << can1Baud; - debugOutput("Got signal to update bauds. 1: " + QString::number(can0Baud) + " 2: " + QString::number(can1Baud)); + qDebug() << "Got signal to update bauds. 1: " << (can0Baud & 0xFFFFFFF) <<" 2: " << (can1Baud & 0xFFFFFFF); + debugOutput("Got signal to update bauds. 1: " + QString::number((can0Baud & 0xFFFFFFF)) + " 2: " + QString::number((can1Baud & 0xFFFFFFF))); buffer[0] = (char)0xF1; //start of a command over serial buffer[1] = 5; //setup canbus buffer[2] = (unsigned char)(can0Baud & 0xFF); //four bytes of ID LSB first @@ -606,6 +606,10 @@ void GVRetSerial::procRXChar(unsigned char c) qDebug() << "Baud 1 = " << can1Baud; mBusData[0].mBus.setSpeed(can0Baud); mBusData[1].mBus.setSpeed(can1Baud); + mBusData[0].mBus.setEnabled(can0Enabled); + mBusData[1].mBus.setEnabled(can1Enabled); + mBusData[0].mConfigured = true; + mBusData[1].mConfigured = true; can0Baud |= 0x80000000; if (can0Enabled) can0Baud |= 0x40000000; @@ -743,6 +747,7 @@ void GVRetSerial::procRXChar(unsigned char c) qDebug() << "LIN1 Baud = " << lin1Baud; qDebug() << "LIN2 Baud = " << lin2Baud; mBusData[2].mBus.setSpeed(swcanBaud); + mBusData[2].mBus.setEnabled(swcanEnabled); setStatus(CANCon::CONNECTED); stats.conStatus = getStatus(); diff --git a/connections/socketcan.cpp b/connections/socketcan.cpp index 3fd9eeb..d370784 100644 --- a/connections/socketcan.cpp +++ b/connections/socketcan.cpp @@ -32,6 +32,7 @@ void SocketCan::piStarted() mTimer.setSingleShot(false); //keep ticking mTimer.start(); mBusData[0].mBus.setEnabled(true); + mBusData[0].mConfigured = true; }