From 11d8364164a7cb708209dffce0fa84099bca2977 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 17 Jan 2017 13:40:42 +0100 Subject: [PATCH] Added PURGE_DATA --- serial/serbridge.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/serial/serbridge.c b/serial/serbridge.c index 5ce6ae0..3c36112 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -44,6 +44,8 @@ serbridgeConnData connData[MAX_CONN]; #define SetDataSize 2 // Set data size #define SetParity 3 // Set parity #define SetControl 5 // Set control lines +#define PurgeData 12 // Flush FIFO buffer(s) +#define PURGE_TX 2 #define BRK_REQ 4 // request current BREAK state #define BRK_ON 5 // set BREAK (TX-line to LOW) #define BRK_OFF 6 // reset BREAK @@ -54,7 +56,7 @@ serbridgeConnData connData[MAX_CONN]; // telnet state machine states enum { TN_normal, TN_iac, TN_will, TN_start, TN_end, TN_comPort, TN_setControl, TN_setBaud, - TN_setDataSize, TN_setParity }; + TN_setDataSize, TN_setParity, TN_purgeData }; static char tn_baudCnt; static uint32_t tn_baud; // shared across all sockets, thus possible race condition static uint8_t tn_break = 0; // 0=BREAK-OFF, 1=BREAK-ON @@ -114,9 +116,18 @@ telnetUnwrap(serbridgeConnData *conn, uint8_t *inBuf, int len) case SetDataSize: state = TN_setDataSize; break; case SetParity: state = TN_setParity; break; case SetBaud: state = TN_setBaud; tn_baudCnt = 0; tn_baud = 0; break; + case PrugeData: state = TN_purgeData; break; default: state = TN_end; break; } break; + case TN_purgeData: // purge FIFO-buffers + switch (c) { + case PURGE_TX: + // TODO: flush TX buffer + break; + } + state = TN_end; + break; case TN_setControl: // switch control line and delay a tad switch (c) { case DTR_ON: