Added sample UART rx code

This commit is contained in:
Maurizio Porrato 2017-02-16 07:36:51 +00:00
parent 5b13ca10e0
commit c6b85087ee
1 changed files with 18 additions and 2 deletions

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <espressif/esp_common.h>
@ -92,8 +94,22 @@ void NetworkConnectionTask(void *p) {
* discarding invalid packets
*/
void SerialDataCollectionTask(void *p) {
for (;;)
vTaskDelay(TIME_MS(5000));
char c;
char buffer[50];
int bufpos = 0;
for (;;) {
if (read(0, (void *)&c, 1)) {
printf("%c", c);
if (bufpos < sizeof(buffer) / sizeof(buffer[0]) - 1)
buffer[bufpos++] = c;
if (c == '\n') {
buffer[bufpos] = '\0';
/* TODO: Send the frame to the shipping task */
bufpos = 0;
}
}
}
}
/* This task sends parsed measurements to the network */