From c0dbc03259034155219297f78115af9353dfdf9d Mon Sep 17 00:00:00 2001 From: georg Date: Wed, 5 Apr 2017 09:46:55 +0200 Subject: [PATCH] added first multiline response handling approach --- Firmware/Chameleon-Mini/Terminal/CommandLine.c | 4 ++++ Software/Chameleon/Device.py | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Firmware/Chameleon-Mini/Terminal/CommandLine.c b/Firmware/Chameleon-Mini/Terminal/CommandLine.c index e62403b6..2e653de1 100644 --- a/Firmware/Chameleon-Mini/Terminal/CommandLine.c +++ b/Firmware/Chameleon-Mini/Terminal/CommandLine.c @@ -436,6 +436,7 @@ static void DecodeCommand(void) TerminalSendString(pTerminalBuffer); TerminalSendStringP(PSTR(OPTIONAL_ANSWER_TRAILER)); } + TerminalSendChar('\0'); } void CommandLineInit(void) @@ -487,6 +488,7 @@ INLINE void Timeout(void) CommandLinePendingTaskTimeout(); // call the function that ends the task CommandLinePendingTaskTimeout = NO_FUNCTION; } + TerminalSendChar('\0'); } void CommandLineTick(void) @@ -521,6 +523,7 @@ void CommandLinePendingTaskFinished(CommandStatusIdType ReturnStatusID, char con TerminalSendString(OutMessage); TerminalSendStringP(PSTR(OPTIONAL_ANSWER_TRAILER)); } + TerminalSendChar('\0'); } void CommandLineAppendData(void const * const Buffer, uint16_t Bytes) @@ -551,4 +554,5 @@ void CommandLineAppendData(void const * const Buffer, uint16_t Bytes) } TerminalSendStringP(PSTR(OPTIONAL_ANSWER_TRAILER)); + TerminalSendChar('\0'); } diff --git a/Software/Chameleon/Device.py b/Software/Chameleon/Device.py index 57169c78..f48a3502 100644 --- a/Software/Chameleon/Device.py +++ b/Software/Chameleon/Device.py @@ -147,9 +147,16 @@ def writeCmd(self, cmd): def readResponse(self): # Read response to command, if any - response = self.serial.readline().decode('ascii').rstrip() + timeout = self.serial.timeout + self.serial.timeout = 1 + response = "" + tmp = self.serial.read(1) + while tmp != b'\0': + response += tmp.decode('ascii') + tmp = self.serial.read(1) self.verboseLog("Response: {}".format(response)) - return response + self.serial.timeout = timeout + return response.rstrip() def execCmd(self, cmd, args=None): if (args is None):