New version number, synched to upgraded GVRET version. Some fixes to make file comparator window work better. Add ability to enter single wire mode from SavvyCAN. Add continuous comm validation to SavvyCAN. It will now continuously make sure the connection seems to be viable and try to reconnect if things went south.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
#ifndef CONFIG
|
||||
#define CONFIG
|
||||
|
||||
#define VERSION 126
|
||||
#define VERSION 127
|
||||
|
||||
//try to keep this in sync.
|
||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||
//less than this number.
|
||||
#define CURRENT_GVRET_VER 319
|
||||
#define CURRENT_GVRET_VER 321
|
||||
|
||||
#endif // CONFIG
|
||||
|
||||
|
||||
@@ -116,8 +116,14 @@ void FileComparatorWindow::calculateDetails()
|
||||
//it would be possible to implement a constructor for FrameData
|
||||
//that sets the bitmap and values to zero. That would be cleaner and better.
|
||||
newData->bitmap = 0;
|
||||
//C++ arrays take the form of a single memory block so zap the whole block at once
|
||||
memset(newData->values, 0, 256 * 8);
|
||||
for (int x = 0; x < 8; x++)
|
||||
{
|
||||
for (int y = 0; y < 256; y++)
|
||||
{
|
||||
newData->values[x][y] = 0;
|
||||
}
|
||||
}
|
||||
//memset(newData->values, 0, 256 * 8);
|
||||
for (int y = 0; y < frame.len; y++)
|
||||
{
|
||||
newData->values[y][frame.data[y]] = 1;
|
||||
@@ -144,7 +150,14 @@ void FileComparatorWindow::calculateDetails()
|
||||
newData->ID = frame.ID;
|
||||
newData->dataLen = frame.len;
|
||||
newData->bitmap = 0;
|
||||
memset(newData->values, 0, 256 * 8);
|
||||
for (int x = 0; x < 8; x++)
|
||||
{
|
||||
for (int y = 0; y < 256; y++)
|
||||
{
|
||||
newData->values[x][y] = 0;
|
||||
}
|
||||
}
|
||||
//memset(newData->values, 0, 256 * 8);
|
||||
for (int y = 0; y < frame.len; y++)
|
||||
{
|
||||
newData->values[y][frame.data[y]] = 1;
|
||||
@@ -185,7 +198,7 @@ void FileComparatorWindow::calculateDetails()
|
||||
sharedItem->addChild(bitmapBaseSecond);
|
||||
|
||||
//first up, which bits were set in one file but not the other
|
||||
for (int b = 0; b < 64; b++)
|
||||
for (int b = 0; b < (8 * first.dataLen); b++)
|
||||
{
|
||||
detail = new QTreeWidgetItem();
|
||||
detail->setText(0, QString::number(b) + " (" + QString::number(b / 8) + ":" + QString::number(b % 8) + ")");
|
||||
@@ -251,7 +264,6 @@ void FileComparatorWindow::calculateDetails()
|
||||
{
|
||||
ui->treeDetails->expandAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FileComparatorWindow::saveDetails()
|
||||
|
||||
@@ -29,6 +29,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
|
||||
ui->cbTimeSeconds->setChecked(settings->value("Main/TimeSeconds", false).toBool());
|
||||
ui->comboSendingBus->setCurrentIndex(settings->value("Playback/SendingBus", 4).toInt());
|
||||
ui->cbUseFiltered->setChecked(settings->value("Main/UseFiltered", false).toBool());
|
||||
ui->cbSingleWire->setChecked(settings->value("Main/SingleWireMode", false).toBool());
|
||||
|
||||
//just for simplicity they all call the same function and that function updates all settings at once
|
||||
connect(ui->cbDisplayHex, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
@@ -43,6 +44,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
|
||||
connect(ui->cbTimeSeconds, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
connect(ui->comboSendingBus, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSettings()));
|
||||
connect(ui->cbUseFiltered, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
connect(ui->cbSingleWire, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||
}
|
||||
|
||||
MainSettingsDialog::~MainSettingsDialog()
|
||||
@@ -70,6 +72,7 @@ void MainSettingsDialog::updateSettings()
|
||||
settings->setValue("Main/TimeSeconds", ui->cbTimeSeconds->isChecked());
|
||||
settings->setValue("Playback/SendingBus", ui->comboSendingBus->currentIndex());
|
||||
settings->setValue("Main/UseFiltered", ui->cbUseFiltered->isChecked());
|
||||
settings->setValue("Main/SingleWireMode", ui->cbSingleWire->isChecked());
|
||||
|
||||
settings->sync();
|
||||
}
|
||||
|
||||
@@ -55,6 +55,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbSingleWire">
|
||||
<property name="text">
|
||||
<string>Put second canbus in single wire mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
+53
-2
@@ -17,6 +17,8 @@ SerialWorker::SerialWorker(CANFrameModel *model, QObject *parent) : QObject(pare
|
||||
elapsedTime = NULL;
|
||||
framesPerSec = 0;
|
||||
capturing = true;
|
||||
gotValidated = true;
|
||||
isAutoRestart = false;
|
||||
|
||||
readSettings();
|
||||
}
|
||||
@@ -50,6 +52,10 @@ void SerialWorker::readSettings()
|
||||
|
||||
void SerialWorker::setSerialPort(QSerialPortInfo *port)
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
currentPort = port;
|
||||
|
||||
if (serial != NULL)
|
||||
{
|
||||
if (serial->isOpen())
|
||||
@@ -61,7 +67,7 @@ void SerialWorker::setSerialPort(QSerialPortInfo *port)
|
||||
delete serial;
|
||||
}
|
||||
|
||||
serial = new QSerialPort(*port);
|
||||
serial = new QSerialPort(*port);
|
||||
|
||||
qDebug() << "Serial port name is " << port->portName();
|
||||
serial->setBaudRate(serial->Baud115200);
|
||||
@@ -77,6 +83,17 @@ void SerialWorker::setSerialPort(QSerialPortInfo *port)
|
||||
output.append(0x06); //request canbus stats from the board
|
||||
output.append(0xF1); //another command to the GVRET
|
||||
output.append(0x07); //request device information
|
||||
output.append(0xF1);
|
||||
output.append(0x08); //setting singlewire mode
|
||||
if (settings.value("Main/SingleWireMode", false).toBool())
|
||||
{
|
||||
output.append(0x10); //signal that we do want single wire mode
|
||||
}
|
||||
else
|
||||
{
|
||||
output.append(0xFF); //signal we don't want single wire mode
|
||||
}
|
||||
|
||||
serial->write(output);
|
||||
if (doValidation) connected = false;
|
||||
else connected = true;
|
||||
@@ -212,6 +229,11 @@ void SerialWorker::procRXChar(unsigned char c)
|
||||
rx_state = GET_DEVICE_INFO;
|
||||
rx_step = 0;
|
||||
break;
|
||||
case 9:
|
||||
gotValidated = true;
|
||||
qDebug() << "Got validated";
|
||||
rx_state = IDLE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BUILD_CAN_FRAME:
|
||||
@@ -365,11 +387,40 @@ void SerialWorker::procRXChar(unsigned char c)
|
||||
void SerialWorker::handleTick()
|
||||
{
|
||||
//qDebug() << "Tick!";
|
||||
|
||||
if (!gotValidated)
|
||||
{
|
||||
if (serial->isOpen()) //if it's still false we have a problem...
|
||||
{
|
||||
qDebug() << "Comm validation failed. ";
|
||||
closeSerialPort(); //start by stopping everything.
|
||||
QTimer::singleShot(500, this, SLOT(handleReconnect()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
framesPerSec += gotFrames * 1000 / elapsedTime->elapsed() - (framesPerSec / 4);
|
||||
elapsedTime->restart();
|
||||
emit frameUpdateTick(framesPerSec / 4, gotFrames); //sends stats to interested parties
|
||||
canModel->sendBulkRefresh(gotFrames);
|
||||
gotFrames = 0;
|
||||
gotFrames = 0;
|
||||
if (doValidation) sendCommValidation();
|
||||
}
|
||||
|
||||
void SerialWorker::handleReconnect()
|
||||
{
|
||||
qDebug() << "Automatically reopening the connection";
|
||||
setSerialPort(currentPort); //then go back through the re-init
|
||||
}
|
||||
|
||||
void SerialWorker::sendCommValidation()
|
||||
{
|
||||
QByteArray output;
|
||||
|
||||
gotValidated = false;
|
||||
output.append(0xF1); //another command to the GVRET
|
||||
output.append(0x09); //request a reply to get validation
|
||||
serial->write(output);
|
||||
}
|
||||
|
||||
//totally shuts down the whole thing
|
||||
|
||||
+7
-1
@@ -20,7 +20,8 @@ enum STATE //keep this enum synchronized with the Arduino firmware project
|
||||
SET_DIG_OUTPUTS,
|
||||
SETUP_CANBUS,
|
||||
GET_CANBUS_PARAMS,
|
||||
GET_DEVICE_INFO
|
||||
GET_DEVICE_INFO,
|
||||
SET_SINGLEWIRE_MODE
|
||||
};
|
||||
|
||||
class SerialWorker : public QObject
|
||||
@@ -43,6 +44,7 @@ private slots: //we receive things in slots
|
||||
void readSerialData();
|
||||
void connectionTimeout();
|
||||
void handleTick();
|
||||
void handleReconnect();
|
||||
|
||||
public slots:
|
||||
void setSerialPort(QSerialPortInfo*);
|
||||
@@ -58,7 +60,10 @@ private:
|
||||
bool connected;
|
||||
bool capturing;
|
||||
bool doValidation;
|
||||
bool gotValidated;
|
||||
bool isAutoRestart;
|
||||
QSerialPort *serial;
|
||||
QSerialPortInfo *currentPort;
|
||||
CANFrameModel *canModel;
|
||||
QTimer *ticker;
|
||||
QTime *elapsedTime;
|
||||
@@ -73,6 +78,7 @@ private:
|
||||
int deviceSingleWireMode;
|
||||
|
||||
void procRXChar(unsigned char);
|
||||
void sendCommValidation();
|
||||
};
|
||||
|
||||
#endif // SERIALTHREAD_H
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
#include "utility.h"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user