summaryrefslogtreecommitdiff
path: root/fw/esp32
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-08-09 03:13:24 +0200
committerUros Majstorovic <majstor@majstor.org>2020-08-09 03:13:24 +0200
commit42ec688338634c9ba3f7fab95fbd230d17e4da1e (patch)
tree5b03e4c0258ab0bcc8f024b1143b8d4c5f1ec4c0 /fw/esp32
parent21dbc40e58a79f487d1ee34129f16e26cb6ba120 (diff)
uart dirty property added
Diffstat (limited to 'fw/esp32')
-rw-r--r--fw/esp32/components/eos/cell_modem.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fw/esp32/components/eos/cell_modem.c b/fw/esp32/components/eos/cell_modem.c
index 4c9271f..c758a73 100644
--- a/fw/esp32/components/eos/cell_modem.c
+++ b/fw/esp32/components/eos/cell_modem.c
@@ -54,6 +54,7 @@ static QueueHandle_t uart_queue;
static char urc_buf[EOS_CELL_UART_SIZE_BUF];
static char uart_buf[EOS_CELL_UART_SIZE_BUF];
static size_t uart_buf_len;
+static char uart_buf_dirty = 0;
static uint8_t uart_mode = EOS_CELL_UART_MODE_ATCMD;
static uint8_t _uart_mode = EOS_CELL_UART_MODE_UNDEF;
@@ -243,13 +244,15 @@ static void modem_atcmd_read(size_t bsize) {
uart_buf_len -= ln_end - uart_buf + 1;
if (uart_buf_len) memmove(uart_buf, ln_end + 1, uart_buf_len);
- at_urc_process(urc_buf);
+ if (!uart_buf_dirty) at_urc_process(urc_buf);
uart_curr = uart_buf;
uart_buf[uart_buf_len] = '\0';
+ uart_buf_dirty = 0;
}
if (uart_buf_len == sizeof(uart_buf) - 1) {
uart_buf_len = 0;
+ uart_buf_dirty = 1;
}
} while (rd != bsize);
}
@@ -633,10 +636,15 @@ int eos_modem_readln(char *buf, size_t buf_size, uint32_t timeout) {
}
while (ln_end == NULL) {
+ int rv = EOS_OK;
int len;
- if (buf_len == buf_size - 1) return EOS_ERR_FULL;
- if (timeout && ((uint32_t)((esp_timer_get_time() - t_start) / 1000) > timeout)) return EOS_ERR_TIMEOUT;
+ if (buf_len == buf_size - 1) rv = EOS_ERR_FULL;
+ if (!rv && timeout && ((uint32_t)((esp_timer_get_time() - t_start) / 1000) > timeout)) rv = EOS_ERR_TIMEOUT;
+ if (rv) {
+ uart_buf_dirty = 1;
+ return rv;
+ }
len = eos_modem_read(buf + buf_len, MIN(buf_size - buf_len - 1, sizeof(uart_buf) - uart_buf_len), 10);
if (len > 0) {