diff --git a/canframemodel.cpp b/canframemodel.cpp index beb978a..a7d9127 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -323,18 +323,23 @@ void CANFrameModel::addFrame(const CANFrame &frame, bool autoRefresh = false) void CANFrameModel::sendRefresh() { + mutex.lock(); qDebug() << "Sending mass refresh"; + QVector tempContainer; beginResetModel(); - filteredFrames.clear(); - for (int i = 0; i < frames.count(); i++) + int count = frames.count(); + for (int i = 0; i < count; i++) { if (filters[frames[i].ID]) { - filteredFrames.append(frames[i]); + tempContainer.append(frames[i]); } } + filteredFrames.clear(); + filteredFrames = tempContainer; lastUpdateNumFrames = filteredFrames.count(); endResetModel(); + mutex.unlock(); } void CANFrameModel::sendRefresh(int pos) @@ -359,6 +364,8 @@ void CANFrameModel::sendBulkRefresh(int num) if (num == 0) return; if (filteredFrames.count() == 0) return; + mutex.lock(); + if (!overwriteDups) { if (num > filteredFrames.count()) num = filteredFrames.count(); @@ -369,6 +376,7 @@ void CANFrameModel::sendBulkRefresh(int num) { sendRefresh(); } + mutex.unlock(); } void CANFrameModel::clearFrames() diff --git a/connectionwindow.cpp b/connectionwindow.cpp index 5c5db26..81826f7 100644 --- a/connectionwindow.cpp +++ b/connectionwindow.cpp @@ -103,6 +103,8 @@ void ConnectionWindow::setSpeeds(int speed0, int speed1) { bool found = false; + qDebug() << speed0 << "X" << speed1; + for (int i = 0; i < ui->cbSpeed0->count(); i++) { if (ui->cbSpeed0->itemText(i).toInt() == speed0) @@ -184,3 +186,14 @@ ConnectionType::ConnectionType ConnectionWindow::getConnectionType() if (ui->rbKvaser->isChecked()) return ConnectionType::KVASER; if (ui->rbSocketCAN->isChecked()) return ConnectionType::SOCKETCAN; } + +void ConnectionWindow::setCAN1SWMode(bool mode) +{ + ui->ckSingleWire->setChecked(mode); +} + +bool ConnectionWindow::getCAN1SWMode() +{ + if (ui->ckSingleWire->checkState() == Qt::Checked) return true; + return false; +} diff --git a/connectionwindow.h b/connectionwindow.h index cb4a437..78df402 100644 --- a/connectionwindow.h +++ b/connectionwindow.h @@ -31,12 +31,14 @@ public: int getSpeed1(); QString getPortName(); //name of port to connect to ConnectionType::ConnectionType getConnectionType(); + bool getCAN1SWMode(); signals: void updateConnectionSettings(QString connectionType, QString port, int speed0, int speed1); public slots: void setSpeeds(int speed0, int speed1); + void setCAN1SWMode(bool mode); private slots: void handleOKButton(); diff --git a/connectionwindow.ui b/connectionwindow.ui index a6e754d..dc48369 100644 --- a/connectionwindow.ui +++ b/connectionwindow.ui @@ -96,6 +96,13 @@ + + + + Set CAN1 to Single Wire Mode + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index cd10c4a..ff4d6e5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -13,8 +13,6 @@ Things that were planned for the GVRET-PC project but never completed. Single / Multi state - The goal is to find bits that change based on toggles or discrete state items (shifters, etc) -Range state - Find things that range like accelerator pedal inputs, road speed, tach, etc - fuzzy scope - Try to find potential places where a given value might be stored - offer guesses and the program tries to find candidates for you or, try to find things that appear to be multi-byte integers */ @@ -321,6 +319,7 @@ void MainWindow::connButtonPress() if (ports[i].portName() == portName) { portInfo = ports[i]; + //need to create some way to send single wire mode to serial port code emit sendSerialPort(&portInfo); lbStatusConnected.setText(tr("Attempting to connect to port ") + portName); } @@ -907,6 +906,7 @@ void MainWindow::connectionSucceeded(int baud0, int baud1) ui->cbSpeed2->setCurrentIndex(ui->cbSpeed2->count() - 1); } */ + connectionWindow->setSpeeds(baud0, baud1); //ui->btnConnect->setEnabled(false); ui->actionConnect->setText(tr("Disconnect")); isConnected = true; @@ -961,6 +961,9 @@ void MainWindow::gotDeviceInfo(int build, int swCAN) + "\n\nPlease upgrade your firmware version.\nOtherwise, you may experience difficulties."); msgBox.exec(); } + + if (swCAN == 1) connectionWindow->setCAN1SWMode(true); + else connectionWindow->setCAN1SWMode(false); } void MainWindow::setTargettedID(int id)