Return exact length

This commit is contained in:
2026-06-17 20:33:38 +02:00
parent 907c0b170d
commit 4afa6702fb
+5 -2
View File
@@ -32,7 +32,7 @@ extern osMessageQueueId_t xUARTQueue;
* @param arguments: buffer, source, message * @param arguments: buffer, source, message
* @retval None * @retval None
*/ */
static void format_can_message(char *buf, uint8_t source, const CanMessage_t *message) static int format_can_message(char *buf, uint8_t source, const CanMessage_t *message)
{ {
const char hex[] = "0123456789ABCDEF"; const char hex[] = "0123456789ABCDEF";
@@ -72,6 +72,9 @@ static void format_can_message(char *buf, uint8_t source, const CanMessage_t *me
buf[idx++] = '\r'; buf[idx++] = '\r';
buf[idx++] = '\n'; buf[idx++] = '\n';
buf[idx] = '\0';
return idx;
} }
/* END format_can_message */ /* END format_can_message */
@@ -108,7 +111,7 @@ void vUARTLogger(void *argument)
{ {
DEBUG_PRINT("CAN frame detected\r\n"); DEBUG_PRINT("CAN frame detected\r\n");
format_can_message(tx_buffer, message.source, &message); format_can_message(tx_buffer, message.source, &message);
HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, 44); HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, len);
osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever); osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
DEBUG_PRINT("CAN frame sent via UART\r\n"); DEBUG_PRINT("CAN frame sent via UART\r\n");
} }