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 <jenkins@radinn.com>
Tested-by: aleksandar rodzevski <aleks@radinn.com>
Reviewed-by: aleksandar rodzevski <aleks@radinn.com>
Reviewed-by: Daniel Nordahl <daniel.nordahl@radinn.com>
This commit is contained in:
rodale75 2022-01-11 10:42:07 +01:00 committed by dnordahl83
parent a30e259549
commit ed88dbe5b0
1 changed files with 13 additions and 0 deletions

13
main.c
View File

@ -55,6 +55,11 @@
#include "mempools.h" #include "mempools.h"
#include "events.h" #include "events.h"
#include "main.h" #include "main.h"
#ifdef CAN_ENABLE
#include "comm_can.h"
#define CAN_FRAME_MAX_PL_SIZE 8
#endif
#ifdef USE_LISPBM #ifdef USE_LISPBM
#include "lispif.h" #include "lispif.h"
@ -309,6 +314,14 @@ int main(void) {
palSetPad(BOOT_OK_GPIO, BOOT_OK_PIN); palSetPad(BOOT_OK_GPIO, BOOT_OK_PIN);
#endif #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(;;) { for(;;) {
chThdSleepMilliseconds(10); chThdSleepMilliseconds(10);
} }