Skip to content

Commit 26981f3

Browse files
author
NoahAndrews
committed
Send disabled heartbeats ASAP after ack timeout expires
1 parent ae04549 commit 26981f3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/canWrapper.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,15 @@ void heartbeatsWatchdog() {
680680
uint8_t disabledRevCommonHeartbeat[] = {0};
681681
for(int i = 0; i < heartbeatsRunning.size(); i++) {
682682
if (sparkHeartbeatMap.contains(heartbeatsRunning[i])) {
683+
// Clear the scheduled heartbeat that has outdated data so that the updated one gets sent out immediately
684+
_sendCANMessage(descriptor, SPARK_HEARTBEAT_ID, disabledSparkHeartbeat, 8, -1);
685+
683686
_sendCANMessage(heartbeatsRunning[i], SPARK_HEARTBEAT_ID, disabledSparkHeartbeat, 8, HEARTBEAT_PERIOD_MS);
684687
}
685688
if (revCommonHeartbeatMap.contains(heartbeatsRunning[i])) {
689+
// Clear the scheduled heartbeat that has outdated data so that the updated one gets sent out immediately
690+
_sendCANMessage(descriptor, REV_COMMON_HEARTBEAT_ID, disabledRevCommonHeartbeat, 1, -1);
691+
686692
_sendCANMessage(heartbeatsRunning[i], REV_COMMON_HEARTBEAT_ID, disabledRevCommonHeartbeat, 1, HEARTBEAT_PERIOD_MS);
687693
}
688694
}
@@ -691,9 +697,15 @@ void heartbeatsWatchdog() {
691697
heartbeatTimeoutExpired = false;
692698
for(int i = 0; i < heartbeatsRunning.size(); i++) {
693699
if (auto heartbeatEntry = sparkHeartbeatMap.find(heartbeatsRunning[i]); heartbeatEntry != sparkHeartbeatMap.end()) {
700+
// Clear the scheduled heartbeat that has outdated data so that the updated one gets sent out immediately
701+
_sendCANMessage(descriptor, SPARK_HEARTBEAT_ID, heartbeatEntry->second.data(), 8, -1);
702+
694703
_sendCANMessage(heartbeatsRunning[i], SPARK_HEARTBEAT_ID, heartbeatEntry->second.data(), 8, HEARTBEAT_PERIOD_MS);
695704
}
696705
if (auto heartbeatEntry = revCommonHeartbeatMap.find(heartbeatsRunning[i]); heartbeatEntry != revCommonHeartbeatMap.end()) {
706+
// Clear the scheduled heartbeat that has outdated data so that the updated one gets sent out immediately
707+
_sendCANMessage(descriptor, REV_COMMON_HEARTBEAT_ID, heartbeatEntry->second.data(), 1, -1);
708+
697709
_sendCANMessage(heartbeatsRunning[i], REV_COMMON_HEARTBEAT_ID, heartbeatEntry->second.data(), 1, HEARTBEAT_PERIOD_MS);
698710
}
699711
}

0 commit comments

Comments
 (0)