Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heartbeat Refactor #1325

Merged
merged 35 commits into from
Dec 29, 2024
Merged

Heartbeat Refactor #1325

merged 35 commits into from
Dec 29, 2024

Conversation

Lucien950
Copy link
Contributor

@Lucien950 Lucien950 commented Jun 23, 2024

Changelist

  • Changed structure of heartbeat monitor config. (see firmware/shared/src/app/app_heartbeatMonitorBoard.h)
  • Gives sturcture towards future app level refactor

Testing Done

  • fixed tests for all boards
  • adapted shared heartbeat monitor to new structure

Resolved Tickets

@Lucien950 Lucien950 requested a review from liam-ilan June 23, 2024 23:14
@Lucien950 Lucien950 self-assigned this Jun 23, 2024
@Lucien950 Lucien950 enabled auto-merge (squash) June 24, 2024 07:15
Copy link
Contributor

@liam-ilan liam-ilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall a huge improvement over the configuration blocks we had earlier - way cleaner. Just some minor notes about the intermediate API layer that we have on every board that wants to use the heartbeat monitor. Other than that lets get this money!

#include "app_canTx.h"
#include "app_canAlerts.h"

HeartbeatMonitorBoard vc_hbmonitor = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This should probably be named something more consistent with the naming scheme on the rest of the codebase (VC_heartbeat_monitor or VC_hb_monitor?)


void app_heartbeatMonitor_checkIn(void)
{
app_canTx_BMS_Heartbeat_set(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can pass the heartbeat setter function to HeartbeatMonitorBoard, so that the hb monitor library can handle this step - then we can expose a method like app_heartbeatMonitorBoard_tick rather than app_heartbeatMonitorBoard_checkIn...

I'm just thinking that for the next dev using the heartbeat monitor, it seems like a reasonable mistake to forget to broadcast the heartbeat manually.


void app_heartbeatMonitor_broadcastFaults(void)
{
if (block_faults)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fault blocking can also be set as a flag in the HeartbeatMonitorBoard struct if we want the end developer to use a flag to disable faults rather than manually checking it.

}

#ifdef TARGET_TEST
void app_heartbeatMonitor_clearFaults(void)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put this target check in the heartbeat monitor library?

{
block_faults = block;
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we can move a lot of the logic in this intermediate heartbeat layer to the heartbeat monitor library, that way the only thing left here will be configuration. Should help the next dev when they need to port a board (this looks like a site for a lot of potential mistakes).

@@ -0,0 +1,84 @@
#include "app_heartbeatMonitor.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same notes from BMS apply here - I think we can move any remaining logic in this file and move it to the heartbeat monitor library, making this just a configuration file.


static bool block_faults = false;

void app_heartbeatMonitor_init(bool block_faults_init)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The init wrapper here is nice though - we should keep this method here.

@Lucien950 Lucien950 added the Build System/DevEx Anything that affects Build System, IDE Integration, Github Actions, Code Deployment label Jul 27, 2024
@Lucien950 Lucien950 closed this Nov 12, 2024
auto-merge was automatically disabled November 12, 2024 05:15

Pull request was closed

@Lucien950 Lucien950 reopened this Dec 28, 2024
Copy link
Contributor

@liam-ilan liam-ilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits - Commented on the BMS implementation but I think most of the comments apply across all boards, ping me when you want another review!

firmware/cmake/tests.cmake Show resolved Hide resolved
firmware/logfs/CMakeLists.txt Show resolved Hide resolved
firmware/quadruna/BMS/src/app/app_heartbeatMonitors.c Outdated Show resolved Hide resolved
firmware/quadruna/BMS/src/app/app_heartbeatMonitors.c Outdated Show resolved Hide resolved
firmware/quadruna/BMS/src/app/app_heartbeatMonitors.c Outdated Show resolved Hide resolved
firmware/quadruna/BMS/src/app/app_heartbeatMonitors.h Outdated Show resolved Hide resolved
firmware/quadruna/BMS/src/tasks.c Show resolved Hide resolved
firmware/quadruna/BMS/test/test_imd.h Show resolved Hide resolved
firmware/shared/src/app/app_heartbeatMonitor.h Outdated Show resolved Hide resolved
@liam-ilan liam-ilan self-requested a review December 29, 2024 00:10
Copy link
Contributor

@liam-ilan liam-ilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Lucien950 Lucien950 merged commit 6939b2d into master Dec 29, 2024
33 checks passed
@Lucien950 Lucien950 deleted the heartbeat_refactor branch December 29, 2024 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build System/DevEx Anything that affects Build System, IDE Integration, Github Actions, Code Deployment
Development

Successfully merging this pull request may close these issues.

2 participants