Hello,
I download TI-RTOS and I compile H52C1 - Example Projects - UART Echo.
I open "uartecho.c" file and I found this snippet
UART_write(uart, echoPrompt, sizeof(echoPrompt));
/* Loop forever echoing */
while (TRUE) {
UART_read(uart, &input, 1);
UART_write(uart, &input, 1);
}
ok: the code wait for only one received UART char and echoes,
but I have this problem: I want to listen for an incoming packet,
decode and answer.
The incoming packet is a sequence of multiple chars without any pause.
The code has to detect the end of the packet and return the packet (chars)
I suspect You have to use one timer like this
#define TIMEOUT 10 //ms
Char incoming_packet[100];
Char* ptr = incoming_packet;
do
{
UART_read(uart, ptr++, 1);
TIMER_reset();
} while (TIMER_get_ms()<TIMEOUT);
int packet_size = (int)(ptr-incoming_packet);
Is there a better way ?
Can someone help me ?
By by