From cdf16985adb37865ed1b3ce66da882100be07464 Mon Sep 17 00:00:00 2001 From: topquark12 Date: Fri, 29 Jan 2021 12:12:01 +0800 Subject: [PATCH 1/2] main: fix double brackets sent when socket rx ring buffer wraps around --- pytec/autotune.py | 7 ++----- src/main.rs | 7 ++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pytec/autotune.py b/pytec/autotune.py index f2e5de5..66bb351 100644 --- a/pytec/autotune.py +++ b/pytec/autotune.py @@ -243,11 +243,8 @@ def main(): lookback, noiseband, ch['interval']) for data in tec.report_mode(): - try: - ch = data[channel] - # Workaround for report_mode may yeild empty object - except KeyError: - continue + + ch = data[channel] temperature = ch['temperature'] diff --git a/src/main.rs b/src/main.rs index f7dd2fb..f7e52d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -213,9 +213,10 @@ fn main() -> ! { socket.close() } else if socket.can_send() && socket.can_recv() { match socket.recv(|buf| session.feed(buf)) { - Ok(SessionInput::Nothing) => { - send_line(&mut socket, b"{}"); - } + // SessionInput::Nothing happens when socket RX ring buffer wraps around without + // the line reader reading a newline character, should do nothing and let + // the line reader read from the start of ring buffer in the next loop cycle. + Ok(SessionInput::Nothing) => {} Ok(SessionInput::Command(command)) => match command { Command::Quit => socket.close(), -- 2.42.0 From 355f10c713c3eb6c4ae0d1ebec4a9428a34c8e51 Mon Sep 17 00:00:00 2001 From: topquark12 Date: Fri, 29 Jan 2021 16:16:59 +0800 Subject: [PATCH 2/2] main: update comment --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index f7e52d9..9a11b7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -213,9 +213,10 @@ fn main() -> ! { socket.close() } else if socket.can_send() && socket.can_recv() { match socket.recv(|buf| session.feed(buf)) { - // SessionInput::Nothing happens when socket RX ring buffer wraps around without - // the line reader reading a newline character, should do nothing and let - // the line reader read from the start of ring buffer in the next loop cycle. + // SessionInput::Nothing happens when the line reader parses a string of characters that is not + // followed by a newline character. Could be due to partial commands not terminated with newline, + // socket RX ring buffer wraps around, or when the command is sent as seperate TCP packets etc. + // Do nothing and feed more data to the line reader in the next loop cycle. Ok(SessionInput::Nothing) => {} Ok(SessionInput::Command(command)) => match command { Command::Quit => -- 2.42.0