2024-11-29 04:14 AM
Hello,
here in my code I want to send the received values of the payload directly to USART2. This works fine if I send less than 20 characters. If I send more, the program chrashed.
case P2P_SERVER_UART_C_WRITE_NO_RESP_EVT:
/* USER CODE BEGIN Service1Char3_WRITE_NO_RESP_EVT */
uint16_t payload_Length = p_Notification->DataTransfered.Length; // conversion uint8 Length to uint16 payload_Length
if(HAL_UART_Transmit_DMA(&huart2, p_Notification->DataTransfered.p_Payload, payload_Length) != HAL_OK)
{
Error_Handler();
}
When I set a breakpoint and check the value of the length, a maximum value of 20 is displayed although the variable SizeUart_C = 50 (in file p2p_server.c).
Why is this the case?
What can I do to transfer more characters?
2024-11-30 01:34 AM
I would like to provide more information on this topic here.
In cubeMX i have set the length of the value to 30 and the length of the "Value length" to Variable because i also want to send less than 30 characters.
Then I checked the variable "SizeUart_C" in the file p2p_server_app.c , which has the value 30.
In my opinion, the problem must lie in this program line:
uint16_t payload_Length = p_Notification->DataTransfered.Length;
However, I cannot understand why the value of “Length” does not become > 20. If I send 19 characters, the value in "payload_Length" is 19, but if I send 22 characters or more, the value here is 20.