CAN1/CAN2 LEDs may remain turned on when no CANrx #1

Closed
opened 2026-06-13 20:25:08 +02:00 by eeeck · 2 comments
Owner

Since LEDs are toggled, they may remain in HIGH status when no CANrx. Fix by actually putting it to LOW state after a few ms of no CANrx. Maybe this can be done with a semaphore.

canlog.c, lines 104-110

void vLED_Heartbeat(void *argument)
{
  /* CODE BEGIN */
  LED_Config *led = (LED_Config*)argument;
  HAL_GPIO_TogglePin(led->port, led->pin);
  /* CODE END */
}

Since LEDs are toggled, they may remain in HIGH status when no CANrx. Fix by actually putting it to LOW state after a few ms of no CANrx. Maybe this can be done with a semaphore. canlog.c, lines [104-110](https://git.erickahmed.com/erickahmed/j1939_logger/src/branch/rtos-timers/Core/Src/canlog.c) ```c void vLED_Heartbeat(void *argument) { /* CODE BEGIN */ LED_Config *led = (LED_Config*)argument; HAL_GPIO_TogglePin(led->port, led->pin); /* CODE END */ } ```
eeeck added the bug label 2026-06-13 20:25:08 +02:00
eeeck self-assigned this 2026-06-13 20:25:09 +02:00
eeeck added this to the Thesis SCRUM project 2026-06-13 20:26:58 +02:00
eeeck moved this to To Do in Thesis SCRUM on 2026-06-13 20:27:04 +02:00
eeeck added this to the v0.1.0 milestone 2026-06-13 22:53:12 +02:00
eeeck moved this to Backlog in Thesis SCRUM on 2026-06-14 11:03:36 +02:00
Author
Owner

One solution may be to set an event flag for a separate LED task when reading an incoming can message

osEventFlagsSet(xCanEventFlags, (hcan->Instance == CAN1) ? 0x01 : 0x02);

Use this to keep write it HIGH for some ms and then write it LOW.

and keep the hearbeat for the error LED, inside the error hanlder

One solution may be to set an event flag for a separate LED task when reading an incoming can message ```c osEventFlagsSet(xCanEventFlags, (hcan->Instance == CAN1) ? 0x01 : 0x02); ``` Use this to keep write it HIGH for some ms and then write it LOW. and keep the hearbeat for the error LED, inside the error hanlder
eeeck removed this from the v0.1.0 milestone 2026-06-14 11:25:24 +02:00
eeeck moved this to In Progress in Thesis SCRUM on 2026-06-14 14:11:49 +02:00
eeeck changed reference from rtos-timers to led-semaphore 2026-06-14 14:20:08 +02:00
eeeck marked the pull request as work in progress 2026-06-14 14:26:06 +02:00
eeeck marked the pull request as ready for review 2026-06-14 14:26:13 +02:00
Author
Owner

Issue was completed by using semaphores that get released inside vCANLoggerListen, which are acquired by vLEDHeartbeat, which in turns triggers a timer. If after the timer end there is not a subsequent semaphore release, the timer stops turning the GPIO pin off.

Issue was completed by using semaphores that get released inside vCANLoggerListen, which are acquired by vLEDHeartbeat, which in turns triggers a timer. If after the timer end there is not a subsequent semaphore release, the timer stops turning the GPIO pin off.
eeeck closed this issue 2026-06-14 16:48:43 +02:00
eeeck moved this to Done in Thesis SCRUM on 2026-06-14 16:50:18 +02:00
Sign in to join this conversation.