CAN Connection Window mostly done now.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
#include "canbus.h"
|
#include "canbus.h"
|
||||||
|
|
||||||
CANBus::CANBus()
|
CANBus::CANBus()
|
||||||
@@ -25,18 +26,22 @@ bool CANBus::operator==(const CANBus& bus) const{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CANBus::setSpeed(int newSpeed){
|
void CANBus::setSpeed(int newSpeed){
|
||||||
|
//qDebug() << "CANBUS SetSpeed = " << newSpeed;
|
||||||
speed = newSpeed;
|
speed = newSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CANBus::setListenOnly(bool mode){
|
void CANBus::setListenOnly(bool mode){
|
||||||
|
//qDebug() << "CANBUS SetListenOnly = " << mode;
|
||||||
listenOnly = mode;
|
listenOnly = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CANBus::setSingleWire(bool mode){
|
void CANBus::setSingleWire(bool mode){
|
||||||
|
//qDebug() << "CANBUS SetSingleWire = " << mode;
|
||||||
singleWire = mode;
|
singleWire = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CANBus::setEnabled(bool mode){
|
void CANBus::setEnabled(bool mode){
|
||||||
|
//qDebug() << "CANBUS SetEnabled = " << mode;
|
||||||
active = mode;
|
active = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,20 +216,6 @@ void ConnectionWindow::handleOKButton()
|
|||||||
conn_p = create(getConnectionType(), getPortName());
|
conn_p = create(getConnectionType(), getPortName());
|
||||||
if(!conn_p)
|
if(!conn_p)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i=0 ; i<conn_p->getNumBuses() ; 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 */
|
/* add connection to model */
|
||||||
connModel->add(conn_p);
|
connModel->add(conn_p);
|
||||||
}
|
}
|
||||||
@@ -480,17 +466,10 @@ 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<int> devTypes = settings.value("connections/types").value<QVector<int>>();
|
QVector<int> devTypes = settings.value("connections/types").value<QVector<int>>();
|
||||||
QList<CANBus> busses = settings.value("connections/busses").value<QList<CANBus>>();
|
|
||||||
|
|
||||||
|
|
||||||
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]);
|
||||||
if(conn_p)
|
|
||||||
{
|
|
||||||
for(int j=0 ; j<conn_p->getNumBuses() ; j++)
|
|
||||||
conn_p->setBusSettings(j, busses.takeFirst());
|
|
||||||
}
|
|
||||||
/* add connection to model */
|
/* add connection to model */
|
||||||
connModel->add(conn_p);
|
connModel->add(conn_p);
|
||||||
}
|
}
|
||||||
@@ -507,23 +486,14 @@ void ConnectionWindow::saveConnections()
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
QVector<QString> portNames;
|
QVector<QString> portNames;
|
||||||
QVector<int> devTypes;
|
QVector<int> devTypes;
|
||||||
QList<CANBus> busses;
|
|
||||||
|
|
||||||
/* 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());
|
||||||
|
|
||||||
for(int i=0 ; i<conn_p->getNumBuses() ; i++)
|
|
||||||
{
|
|
||||||
CANBus bus;
|
|
||||||
conn_p->getBusSettings(i, bus);
|
|
||||||
busses.append(bus);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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/busses", QVariant::fromValue(busses));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,8 +148,8 @@ void GVRetSerial::piSetBusSettings(int pBusIdx, CANBus bus)
|
|||||||
if (pBusIdx < 2) {
|
if (pBusIdx < 2) {
|
||||||
/* update baud rates */
|
/* update baud rates */
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
qDebug() << "Got signal to update bauds. 1: " << can0Baud <<" 2: " << can1Baud;
|
qDebug() << "Got signal to update bauds. 1: " << (can0Baud & 0xFFFFFFF) <<" 2: " << (can1Baud & 0xFFFFFFF);
|
||||||
debugOutput("Got signal to update bauds. 1: " + QString::number(can0Baud) + " 2: " + QString::number(can1Baud));
|
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[0] = (char)0xF1; //start of a command over serial
|
||||||
buffer[1] = 5; //setup canbus
|
buffer[1] = 5; //setup canbus
|
||||||
buffer[2] = (unsigned char)(can0Baud & 0xFF); //four bytes of ID LSB first
|
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;
|
qDebug() << "Baud 1 = " << can1Baud;
|
||||||
mBusData[0].mBus.setSpeed(can0Baud);
|
mBusData[0].mBus.setSpeed(can0Baud);
|
||||||
mBusData[1].mBus.setSpeed(can1Baud);
|
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;
|
can0Baud |= 0x80000000;
|
||||||
if (can0Enabled) can0Baud |= 0x40000000;
|
if (can0Enabled) can0Baud |= 0x40000000;
|
||||||
@@ -743,6 +747,7 @@ void GVRetSerial::procRXChar(unsigned char c)
|
|||||||
qDebug() << "LIN1 Baud = " << lin1Baud;
|
qDebug() << "LIN1 Baud = " << lin1Baud;
|
||||||
qDebug() << "LIN2 Baud = " << lin2Baud;
|
qDebug() << "LIN2 Baud = " << lin2Baud;
|
||||||
mBusData[2].mBus.setSpeed(swcanBaud);
|
mBusData[2].mBus.setSpeed(swcanBaud);
|
||||||
|
mBusData[2].mBus.setEnabled(swcanEnabled);
|
||||||
|
|
||||||
setStatus(CANCon::CONNECTED);
|
setStatus(CANCon::CONNECTED);
|
||||||
stats.conStatus = getStatus();
|
stats.conStatus = getStatus();
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ void SocketCan::piStarted()
|
|||||||
mTimer.setSingleShot(false); //keep ticking
|
mTimer.setSingleShot(false); //keep ticking
|
||||||
mTimer.start();
|
mTimer.start();
|
||||||
mBusData[0].mBus.setEnabled(true);
|
mBusData[0].mBus.setEnabled(true);
|
||||||
|
mBusData[0].mConfigured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user