Fixed a nasty bug that could cause the whole program to crash when

changing ID filters. Made the new connection screen update to
show the set baud rates. Added the ability to set Single Wire mode on
the connection window but it actually doesn't work yet.
This commit is contained in:
Collin Kidder
2015-12-28 18:51:07 -05:00
parent a37dbe33aa
commit 5facfe72aa
5 changed files with 38 additions and 5 deletions
+11 -3
View File
@@ -323,18 +323,23 @@ void CANFrameModel::addFrame(const CANFrame &frame, bool autoRefresh = false)
void CANFrameModel::sendRefresh()
{
mutex.lock();
qDebug() << "Sending mass refresh";
QVector<CANFrame> 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()
+13
View File
@@ -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;
}
+2
View File
@@ -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();
+7
View File
@@ -96,6 +96,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="ckSingleWire">
<property name="text">
<string>Set CAN1 to Single Wire Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnOK">
<property name="text">
+5 -2
View File
@@ -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)