[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]
Search found 3 matches
- 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: 14107
- 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: 14107
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 ...
- 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: 14107
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...