Skip to content

Commit 4e9e3f5

Browse files
committed
Merge pull request arduino#400 from mysensors/fix-send-multiple-commands-serial
Allow sending multiple commands in one serial transmission
2 parents 5c650dc + ce6915a commit 4e9e3f5

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

libraries/MySensors/core/MyGatewayTransportSerial.cpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ bool gatewayTransportInit() {
4343

4444

4545
bool gatewayTransportAvailable() {
46-
bool available = false;
47-
4846
while (MY_SERIALDEVICE.available()) {
4947
// get the new byte:
5048
char inChar = (char) MY_SERIALDEVICE.read();
5149
// if the incoming character is a newline, set a flag
5250
// so the main loop can do something about it:
53-
if (_serialInputPos < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1 && !available) {
51+
if (_serialInputPos < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1) {
5452
if (inChar == '\n') {
5553
_serialInputString[_serialInputPos] = 0;
56-
available = true;
54+
bool ok = protocolParse(_serialMsg, _serialInputString);
55+
_serialInputPos = 0;
56+
return ok;
5757
} else {
5858
// add it to the inputString:
5959
_serialInputString[_serialInputPos] = inChar;
@@ -64,12 +64,7 @@ bool gatewayTransportAvailable() {
6464
_serialInputPos = 0;
6565
}
6666
}
67-
if (available) {
68-
// Parse message and return parse result
69-
available = protocolParse(_serialMsg, _serialInputString);
70-
_serialInputPos = 0;
71-
}
72-
return available;
67+
return false;
7368
}
7469

7570
MyMessage & gatewayTransportReceive() {

0 commit comments

Comments
 (0)