Merge pull request #244 from mysensors/fix-ethernet-message-parsing-error
Fix problem with string termination of incoming ethernet messages.
This commit is contained in:
@@ -184,19 +184,13 @@ bool _readFromClient(uint8_t i) {
|
|||||||
char inChar = clients[i].read();
|
char inChar = clients[i].read();
|
||||||
if (inputString[i].idx < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1) {
|
if (inputString[i].idx < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1) {
|
||||||
// if newline then command is complete
|
// if newline then command is complete
|
||||||
if (inChar == '\n') {
|
if (inChar == '\n' || inChar == '\r') {
|
||||||
// a command was issued by the client
|
// Add string terminator and prepare for the next message
|
||||||
// we will now try to send it to the actuator
|
|
||||||
// echo the string to the serial port
|
|
||||||
debug(PSTR("Client %d: %s\n"), i, inputString[i].string);
|
|
||||||
|
|
||||||
// clear the string:
|
|
||||||
inputString[i].idx = 0;
|
|
||||||
|
|
||||||
bool ret = protocolParse(_ethernetMsg, inputString[i].string);
|
|
||||||
inputString[i].string[inputString[i].idx] = 0;
|
inputString[i].string[inputString[i].idx] = 0;
|
||||||
if (ret) {
|
debug(PSTR("Client %d: %s\n"), i, inputString[i].string);
|
||||||
return ret;
|
inputString[i].idx = 0;
|
||||||
|
if (protocolParse(_ethernetMsg, inputString[i].string)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user