@@ -719,9 +719,13 @@ void startRevCommonHeartbeat(const Napi::CallbackInfo& info) {
719
719
}
720
720
721
721
std::array<uint8_t , 1 > payload = {1 };
722
- _sendCANMessage (descriptor, REV_COMMON_HEARTBEAT_ID, payload.data (), 1 , HEARTBEAT_PERIOD_MS);
723
722
724
723
std::scoped_lock lock{watchdogMtx};
724
+
725
+ if (!heartbeatTimeoutExpired) {
726
+ _sendCANMessage (descriptor, REV_COMMON_HEARTBEAT_ID, payload.data (), 1 , HEARTBEAT_PERIOD_MS);
727
+ }
728
+
725
729
revCommonHeartbeatMap[descriptor] = payload;
726
730
727
731
if (heartbeatsRunning.size () == 0 ) {
@@ -753,18 +757,21 @@ void setSparkMaxHeartbeatData(const Napi::CallbackInfo& info) {
753
757
if (deviceIterator == canDeviceMap.end ()) return ;
754
758
}
755
759
756
- // Clear the scheduled heartbeat that has outdated data so that the updated one gets sent out immediately
757
- _sendCANMessage (descriptor, SPARK_HEARTBEAT_ID, heartbeat.data (), 8 , -1 );
758
-
759
760
int sum = 0 ;
760
761
for (uint32_t i = 0 ; i < dataParam.Length (); i++) {
761
762
heartbeat[i] = dataParam.Get (i).As <Napi::Number>().Uint32Value ();
762
763
sum+= heartbeat[i];
763
764
}
764
765
765
- _sendCANMessage (descriptor, SPARK_HEARTBEAT_ID, heartbeat.data (), 8 , HEARTBEAT_PERIOD_MS);
766
-
767
766
std::scoped_lock lock{watchdogMtx};
767
+
768
+ if (!heartbeatTimeoutExpired) {
769
+ // Clear the scheduled heartbeat that has outdated data so that the updated one gets sent out immediately
770
+ _sendCANMessage (descriptor, SPARK_HEARTBEAT_ID, heartbeat.data (), 8 , -1 );
771
+
772
+ _sendCANMessage (descriptor, SPARK_HEARTBEAT_ID, heartbeat.data (), 8 , HEARTBEAT_PERIOD_MS);
773
+ }
774
+
768
775
sparkHeartbeatMap[descriptor] = heartbeat;
769
776
770
777
if (heartbeatsRunning.size () == 0 ) {
0 commit comments