24static IntervalTimer canbusPinUpdate;
25static elapsedMillis lastBeat;
26static volatile int lastTime = 0;
30static std::set<beatFunc> funcs;
32static void toggleLED() {
33 static bool on =
false;
39 Canbus::sendData(ADD_HEART);
42 for (
auto f : funcs) {
48 canbusPinUpdate.priority(10);
52static void receiveBeat(uint32_t,
volatile uint8_t *) {
59 Canbus::addCallback(ADD_HEART, receiveBeat);
64 Log.
w(ID,
"Heartbeat is taking too long", lastBeat);
65 Log.
p(
"lag",
"Heartbeat is taking too long", lastBeat);
Configure global build properties.
#define CONF_HEARTBEAT_INTERVAL_MILLIS
The interval the beat should target.
#define CONF_HEARTBEAT_TIMEOUT_MILLI
The allowed delay between beats.
Make one ECU tell the other it is alive.
Special logging functionality.
const char * LOG_TAG
Type definition of logging tags This typedef is necessary to allow for easier manipulation of code by...
Logging::Log_t Log
The global logging object.
Update, set, and get predefined pin values.
A module used to both ensure a connection to both ECUs using CAN and to periodically run callbacks.
void addCallback(beatFunc func)
Add a callback to be run at each haertbeat.
void beginReceiving()
Set callback to receive beats over CAN.
int checkBeat()
Poll if a beat has been received.
void(* beatFunc)(void)
Function called each time the heart beats.
void beginBeating()
begin sending a beat signal at a set interval
void setPinValue(uint8_t GPIO_Pin, int value)
Set the pin value of a predefined pin.
void w(LOG_TAG TAG, LOG_MSG message)
Log a string using a warning tag.
void p(LOG_TAG name, LOG_MSG prettyName, const uint32_t number, int mediate=false)
Post a monitored value.