Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiline response handling #105

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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