Add mute mode, fix bugs. Sniffer window seems to work well now.

This commit is contained in:
Collin Kidder
2018-10-23 21:04:59 -04:00
parent fbc71103af
commit 66ad108f82
4 changed files with 19 additions and 8 deletions
+12 -4
View File
@@ -16,8 +16,8 @@ SnifferItem::SnifferItem(const CANFrame& pFrame, quint32 seq):
mLastMarker = mMarker; mLastMarker = mMarker;
mCurrent.len = pFrame.len; mCurrent.len = pFrame.len;
/* that's dirty */ /* that's dirty */
update(pFrame, seq); update(pFrame, seq, false);
update(pFrame, seq); update(pFrame, seq, false);
} }
@@ -85,8 +85,12 @@ int SnifferItem::elapsed() const
} }
//called when a new frame comes in that matches our same ID //called when a new frame comes in that matches our same ID
void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq) //timeSeq is stored so we can figure out the last time a specific byte was updated
//mute is used to specify whether to mask the byte against the notching filter
//in order to hide any updates of the notched bits. This is toggleable
void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq, bool mute)
{ {
unsigned char maskedCurr, maskedData;
//qDebug() << "update with ts: " << timeSeq; //qDebug() << "update with ts: " << timeSeq;
/* copy current to last */ /* copy current to last */
mLast = mCurrent; mLast = mCurrent;
@@ -95,7 +99,11 @@ void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq)
/* copy new value */ /* copy new value */
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
if (mCurrent.data[i] != pFrame.data[i]) maskedData = pFrame.data[i];
if (mute) maskedData &= ~mNotch[i];
maskedCurr = mCurrent.data[i];
if (mute) maskedCurr &= ~mNotch[i];
if (maskedCurr != maskedData)
{ {
mCurrent.data[i] = pFrame.data[i]; mCurrent.data[i] = pFrame.data[i];
mCurrent.dataTimestamp[i] = timeSeq; mCurrent.dataTimestamp[i] = timeSeq;
+1 -1
View File
@@ -32,7 +32,7 @@ public:
quint32 getDataTimestamp(uchar i) const; quint32 getDataTimestamp(uchar i) const;
dc dataChange(uchar) const; dc dataChange(uchar) const;
int elapsed() const; int elapsed() const;
void update(const CANFrame& pFrame, quint32 timeSeq); void update(const CANFrame& pFrame, quint32 timeSeq, bool mute);
void updateMarker(); void updateMarker();
void notch(bool); void notch(bool);
+2 -2
View File
@@ -284,14 +284,14 @@ void SnifferModel::update(CANConnection*, QVector<CANFrame>& pFrames)
/* add the frame */ /* add the frame */
beginInsertRows(QModelIndex(), index, index); beginInsertRows(QModelIndex(), index, index);
mMap[frame.ID] = new SnifferItem(frame, mTimeSequence); mMap[frame.ID] = new SnifferItem(frame, mTimeSequence);
mMap[frame.ID]->update(frame, mTimeSequence); mMap[frame.ID]->update(frame, mTimeSequence, mMuteNotched);
endInsertRows(); endInsertRows();
emit idChange(frame.ID, true); emit idChange(frame.ID, true);
} }
else else
//updateData //updateData
mMap[frame.ID]->update(frame, mTimeSequence); mMap[frame.ID]->update(frame, mTimeSequence, mMuteNotched);
} }
} }
+4 -1
View File
@@ -129,7 +129,10 @@ void SnifferWindow::idChange(int pId, bool pAdd)
QString text = QString("0x") + QString("%1").arg(pId, 3, 16, QLatin1Char('0')).toUpper(); QString text = QString("0x") + QString("%1").arg(pId, 3, 16, QLatin1Char('0')).toUpper();
item = new QListWidgetItem(text); item = new QListWidgetItem(text);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
item->setCheckState(mFilter ? Qt::Unchecked : Qt::Checked); //item->setCheckState(mFilter ? Qt::Unchecked : Qt::Checked);
//always check new IDs now. Otherwise any that expire then come back will not be selected
//and that might be a bigger issue than defaulting them unselected.
item->setCheckState(Qt::Checked);
ui->listWidget->addItem(item); ui->listWidget->addItem(item);
mMap[pId] = item; mMap[pId] = item;
} }