From a74177383a2ebb2458ba3a341daba015ed5d6ba3 Mon Sep 17 00:00:00 2001 From: Thorsten von Eicken Date: Sat, 8 Aug 2015 00:53:55 -0700 Subject: [PATCH] fix serial bridge problem --- serial/serbridge.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/serial/serbridge.c b/serial/serbridge.c index c4306f7..5c00175 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -26,16 +26,7 @@ serbridgeConnData connData[MAX_CONN]; // Given a pointer to an espconn struct find the connection that correcponds to it static serbridgeConnData ICACHE_FLASH_ATTR *serbridgeFindConnData(void *arg) { struct espconn *conn = arg; - return (serbridgeConnData *)conn->reverse; -#if 0 - for (int i=0; ireverse; } //===== TCP -> UART @@ -293,8 +284,12 @@ tcpClientProcess(char *buf, int len) if (c == '\n') tcState = TC_newline; break; case TC_newline: // saw newline, expect ~ - if (c == '~') tcState = TC_start; - continue; // gobble up the ~ + if (c == '~') { + tcState = TC_start; + continue; // gobble up the ~ + } else { + break; + } case TC_start: // saw ~, expect channel number if (c == '@') { tcState = TC_cmd; @@ -373,7 +368,7 @@ tcpClientProcess(char *buf, int len) } *out++ = c; } - if (tcState != TC_idle) os_printf("tcState=%d\n", tcState); + //if (tcState != TC_idle) os_printf("tcState=%d\n", tcState); return out-buf; } @@ -387,7 +382,7 @@ serbridgeUartCb(char *buf, int length) { length = tcpClientProcess(buf, length); // push the buffer into each open connection if (length > 0) { - for (int i = 0; i < MAX_CONN; ++i) { + for (int i=0; i