Skip to content

Commit

Permalink
Adding code to Receiver::checkPacketTimeout() that checks for short B…
Browse files Browse the repository at this point in the history
…REAKs if a MAB >= 44us is detected via IDLE.
  • Loading branch information
ssilverman committed Jul 22, 2019
1 parent 4c731cd commit 720dc70
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/Receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,16 +477,22 @@ void Receiver::completePacket() {
}

void Receiver::checkPacketTimeout() {
if (state_ != RecvStates::kData) {
return;
}
uint32_t t = micros(); // It's not clear what to subtract to get the IDLE
// start time
if ((t - breakStartTime_) > kMaxDMXPacketTime ||
(t - lastSlotEndTime_) >= kMaxDMXIdleTime) {
packetTimeoutCount_++;
completePacket();
setConnected(false);
uint32_t t = micros();

if (state_ == RecvStates::kBreak) {
// This catches the case where a short BREAK is followed by a longer MAB
if ((t - breakStartTime_) < 88 + 44) {
framingErrorCount_++;
completePacket();
setConnected(false);
}
} else if (state_ == RecvStates::kData) {
if ((t - breakStartTime_) > kMaxDMXPacketTime ||
(t - lastSlotEndTime_) >= kMaxDMXIdleTime) {
packetTimeoutCount_++;
completePacket();
setConnected(false);
}
}
}

Expand Down

0 comments on commit 720dc70

Please sign in to comment.