Skip to content

Commit

Permalink
added first multiline response handling approach
Browse files Browse the repository at this point in the history
  • Loading branch information
georg committed Apr 5, 2017
1 parent 2ed4034 commit c0dbc03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Firmware/Chameleon-Mini/Terminal/CommandLine.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ static void DecodeCommand(void)
TerminalSendString(pTerminalBuffer);
TerminalSendStringP(PSTR(OPTIONAL_ANSWER_TRAILER));
}
TerminalSendChar('\0');
}

void CommandLineInit(void)
Expand Down Expand Up @@ -487,6 +488,7 @@ INLINE void Timeout(void)
CommandLinePendingTaskTimeout(); // call the function that ends the task
CommandLinePendingTaskTimeout = NO_FUNCTION;
}
TerminalSendChar('\0');
}

void CommandLineTick(void)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -551,4 +554,5 @@ void CommandLineAppendData(void const * const Buffer, uint16_t Bytes)
}

TerminalSendStringP(PSTR(OPTIONAL_ANSWER_TRAILER));
TerminalSendChar('\0');
}
11 changes: 9 additions & 2 deletions Software/Chameleon/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c0dbc03

Please sign in to comment.