From ed88dbe5b09d59f2c6fb418f4ea3423a51360772 Mon Sep 17 00:00:00 2001 From: rodale75 Date: Tue, 11 Jan 2022 10:42:07 +0100 Subject: [PATCH] main: Added CAN boot-frame notification. The boot CAN frame is dispatched at system boot and contains a payload that holds the hw-name (ASCII). This to serve as a notifier for other nodes on the CAN bus. Change-Id: I2edb3d58bb51003d9160ceb83905cf93b63a9396 Reviewed-on: https://review.gerrithub.io/c/RadinnAB/vedder_vesc_fw/+/530857 Tested-by: Mr. Jenkins Tested-by: aleksandar rodzevski Reviewed-by: aleksandar rodzevski Reviewed-by: Daniel Nordahl --- main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.c b/main.c index c766bafe..eb300295 100644 --- a/main.c +++ b/main.c @@ -55,6 +55,11 @@ #include "mempools.h" #include "events.h" #include "main.h" +#ifdef CAN_ENABLE +#include "comm_can.h" + +#define CAN_FRAME_MAX_PL_SIZE 8 +#endif #ifdef USE_LISPBM #include "lispif.h" @@ -309,6 +314,14 @@ int main(void) { palSetPad(BOOT_OK_GPIO, BOOT_OK_PIN); #endif +#ifdef CAN_ENABLE + // Transmit a CAN boot-frame to notify other nodes on the bus about it. + comm_can_transmit_eid( + app_get_configuration()->controller_id | (CAN_PACKET_NOTIFY_BOOT << 8), + (uint8_t *)HW_NAME, (strlen(HW_NAME) <= CAN_FRAME_MAX_PL_SIZE) ? + strlen(HW_NAME) : CAN_FRAME_MAX_PL_SIZE); +#endif + for(;;) { chThdSleepMilliseconds(10); }