Search found 3 matches

by mcsteve237
Tue Jun 19, 2018 5:18 pm
Forum: General Discussion
Topic: How can I flush UART of ESP32 each time I receive a new message?
Replies: 7
Views: 12870

Re: How can I flush UART of ESP32 each time I receive a new message?

[quote="fly135"]Along the lines of what Martin said...

replace this....

for(size_t i = 0; i < rxBytes; i++){
message = data;

with this....

strcpy(message, data);[Its not working since data is unsigned]
by mcsteve237
Tue Jun 19, 2018 4:44 am
Forum: General Discussion
Topic: How can I flush UART of ESP32 each time I receive a new message?
Replies: 7
Views: 12870

Re: How can I flush UART of ESP32 each time I receive a new message?

Yes. My wish is to empty the rx buffer so that the next incoming data will be read properly. The problem I have now is that when I read from rx buffer I can see part of the previous data that was read. For Example Hallo World // "Hallo World" is my first data in the rx buffer byelo World //"bye" is ...
by mcsteve237
Mon Jun 18, 2018 7:11 pm
Forum: General Discussion
Topic: How can I flush UART of ESP32 each time I receive a new message?
Replies: 7
Views: 12870

How can I flush UART of ESP32 each time I receive a new message?

char *readData(){ const int RX_BUF_SIZE = 1024; static const char *RX_TASK_TAG = "RX_TASK"; esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO); uint8_t* data = (uint8_t*) malloc(RX_BUF_SIZE+1); static char message[RX_BUF_SIZE]; const int rxBytes = uart_read_bytes(UART_NUM_0, data, RX_BUF_SIZE, 10 / portTI...