Adding a LF to a string of unkown length
Hello Everybody,
I am wondering if this is good code when using an embedded system or if I should avoid adding a LF to an unkown string like I do it here, since this could overwerite other data in the following address:
void USART_transmit_message(volatile uint8_t *message)
{
if(!strchr(message, '\n')) strcat(message,"\n");
strncpy(USARTBufferTX, message, sizeof(USARTBufferTX));
if(huart1.gState == HAL_UART_STATE_READY)
{
if(HAL_UART_Transmit_DMA(&huart1, &USARTBufferTX, strlen(message))!= HAL_OK)
{
Error_Handler();
}
}
}best regards
Benjamin