Skip to content

Commit b0c5fa8

Browse files
committed
SocketCANAnalyzer: fixed bug causing garbage to be read if bus was idle for a long time
1 parent 48ed319 commit b0c5fa8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scopehal/SocketCANAnalyzer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ bool SocketCANAnalyzer::AcquireData()
247247
int64_t sec;
248248
int64_t ns;
249249
int nbytes = transport->ReadPacket(&frame, sec, ns);
250-
if(nbytes < 0)
250+
if(nbytes <= 0)
251251
break;
252252

253253
//Calculate delay since start of capture, wrapping properly around second boundaries
@@ -269,6 +269,11 @@ bool SocketCANAnalyzer::AcquireData()
269269
//bool ext = (frame.can_id & CAN_EFF_MASK) > 2047;
270270
bool rtr = (frame.can_id & CAN_RTR_FLAG) == CAN_RTR_FLAG;
271271

272+
//If the packet is an error, discard and move on
273+
bool err = (frame.can_id & CAN_ERR_FLAG);
274+
if(err)
275+
continue;
276+
272277
cap->m_offsets.push_back(trel);
273278
cap->m_durations.push_back(ui);
274279
cap->m_samples.push_back(CANSymbol(CANSymbol::TYPE_SOF, 0));

0 commit comments

Comments
 (0)