@@ -9,6 +9,8 @@ SnifferItem::SnifferItem(const CANFrame& pFrame, quint32 seq):
9
9
const unsigned char *data = reinterpret_cast <const unsigned char *>(pFrame.payload ().constData ());
10
10
int dataLen = pFrame.payload ().length ();
11
11
12
+ if (dataLen > MAX_BYTES) dataLen = MAX_BYTES;
13
+
12
14
for (int i = 0 ; i < dataLen; i++) {
13
15
mNotch [i] = 0 ;
14
16
mMarker .data [i] = 0 ;
@@ -41,7 +43,7 @@ float SnifferItem::getDelta() const
41
43
return ((float )(mCurrentTime -mLastTime ))/1000000 ;
42
44
}
43
45
44
- // Get a data byte by index 0-7 (but not more than the length of the actual frame)
46
+ // Get a data byte by index 0-63 (but not more than the length of the actual frame)
45
47
int SnifferItem::getData (uchar i) const
46
48
{
47
49
return (i >= mCurrent .len ) ? -1 : mCurrent .data [i];
@@ -67,7 +69,7 @@ quint32 SnifferItem::getSeqInterval(uchar i) const
67
69
return mCurrSeqVal - getDataTimestamp (i);
68
70
}
69
71
70
- // Return whether a given data byte (by index 0-7 ) has incremented, deincremented, or stayed the same
72
+ // Return whether a given data byte (by index 0-63 ) has incremented, deincremented, or stayed the same
71
73
// since the last message
72
74
// The If checks first that we aren't past the actual data length
73
75
// then checks whether lastMarker shows that some bits have changed in the previous 200ms cycle
@@ -120,6 +122,8 @@ void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq, bool mute)
120
122
const unsigned char *data = reinterpret_cast <const unsigned char *>(pFrame.payload ().constData ());
121
123
int dataLen = pFrame.payload ().length ();
122
124
125
+ if (dataLen > MAX_BYTES) dataLen = MAX_BYTES;
126
+
123
127
/* copy new value */
124
128
for (int i = 0 ; i < dataLen; i++)
125
129
{
@@ -139,7 +143,7 @@ void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq, bool mute)
139
143
/* update marker */
140
144
// We "OR" our stored marker with the changed bits.
141
145
// this accumulates changed bits into the marker
142
- for (int i = 0 ; i < 8 ; i++) mMarker .data [i] |= mLast .data [i] ^ mCurrent .data [i]; // XOR causes only changed bits to be 1's
146
+ for (int i = 0 ; i < MAX_BYTES ; i++) mMarker .data [i] |= mLast .data [i] ^ mCurrent .data [i]; // XOR causes only changed bits to be 1's
143
147
mMarker .len |= mLast .len ^ mCurrent .len ;
144
148
145
149
/* restart timeout */
@@ -151,17 +155,17 @@ void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq, bool mute)
151
155
void SnifferItem::updateMarker ()
152
156
{
153
157
mLastMarker = mMarker ;
154
- for (int i = 0 ; i < 8 ; i++) mMarker .data [i] = 0 ;
158
+ for (int i = 0 ; i < MAX_BYTES ; i++) mMarker .data [i] = 0 ;
155
159
}
156
160
157
161
// Notch or un-notch this snifferitem / frame
158
162
void SnifferItem::notch (bool pNotch)
159
163
{
160
164
if (pNotch)
161
165
{
162
- for (int i = 0 ; i < 8 ; i++) mNotch [i] |= mLastMarker .data [i]; // add changed bits to notch value
166
+ for (int i = 0 ; i < MAX_BYTES ; i++) mNotch [i] |= mLastMarker .data [i]; // add changed bits to notch value
163
167
}
164
168
165
169
else
166
- for (int i = 0 ; i < 8 ; i++) mNotch [i] = 0 ;
170
+ for (int i = 0 ; i < MAX_BYTES ; i++) mNotch [i] = 0 ;
167
171
}
0 commit comments