Add mute mode, fix bugs. Sniffer window seems to work well now.
This commit is contained in:
@@ -16,8 +16,8 @@ SnifferItem::SnifferItem(const CANFrame& pFrame, quint32 seq):
|
||||
mLastMarker = mMarker;
|
||||
mCurrent.len = pFrame.len;
|
||||
/* that's dirty */
|
||||
update(pFrame, seq);
|
||||
update(pFrame, seq);
|
||||
update(pFrame, seq, false);
|
||||
update(pFrame, seq, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,8 +85,12 @@ int SnifferItem::elapsed() const
|
||||
}
|
||||
|
||||
//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;
|
||||
/* copy current to last */
|
||||
mLast = mCurrent;
|
||||
@@ -95,7 +99,11 @@ void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq)
|
||||
/* copy new value */
|
||||
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.dataTimestamp[i] = timeSeq;
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
quint32 getDataTimestamp(uchar i) const;
|
||||
dc dataChange(uchar) const;
|
||||
int elapsed() const;
|
||||
void update(const CANFrame& pFrame, quint32 timeSeq);
|
||||
void update(const CANFrame& pFrame, quint32 timeSeq, bool mute);
|
||||
void updateMarker();
|
||||
void notch(bool);
|
||||
|
||||
|
||||
@@ -284,14 +284,14 @@ void SnifferModel::update(CANConnection*, QVector<CANFrame>& pFrames)
|
||||
/* add the frame */
|
||||
beginInsertRows(QModelIndex(), index, index);
|
||||
mMap[frame.ID] = new SnifferItem(frame, mTimeSequence);
|
||||
mMap[frame.ID]->update(frame, mTimeSequence);
|
||||
mMap[frame.ID]->update(frame, mTimeSequence, mMuteNotched);
|
||||
endInsertRows();
|
||||
|
||||
emit idChange(frame.ID, true);
|
||||
}
|
||||
else
|
||||
//updateData
|
||||
mMap[frame.ID]->update(frame, mTimeSequence);
|
||||
mMap[frame.ID]->update(frame, mTimeSequence, mMuteNotched);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,10 @@ void SnifferWindow::idChange(int pId, bool pAdd)
|
||||
QString text = QString("0x") + QString("%1").arg(pId, 3, 16, QLatin1Char('0')).toUpper();
|
||||
item = new QListWidgetItem(text);
|
||||
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);
|
||||
mMap[pId] = item;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user