Skip to content

Commit b1b0e1d

Browse files
committed
Fixed the bug when calling LineFollow::config(uint8_t,uint8_t,uint8_t,uint8_t) where data was read in reverse order. In C++ the order of evaluation of function arguments is unspecified.
1 parent 42bd006 commit b1b0e1d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

avr/libraries/LottieLemon/src/utility/LottieLemonMotorBoard.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ bool MotorBoard::handleMessage(uint8_t command, IntegerEasyTransfer & request) {
8282
int value;
8383
int speedL;
8484
int speedR;
85+
uint8_t kP;
86+
uint8_t kD;
87+
uint8_t robotSpeedPct;
88+
uint8_t integrationTimeMillis;
8589
//Serial.println("data received");
8690
//Serial.println(command);
8791
switch (command) {
@@ -127,12 +131,11 @@ bool MotorBoard::handleMessage(uint8_t command, IntegerEasyTransfer & request) {
127131
pauseMode(request.readByte());//onOff state
128132
break;
129133
case COMMAND_LINE_FOLLOW_CONFIG:
130-
LineFollow::config(
131-
request.readByte(), //KP
132-
request.readByte(), //KD
133-
request.readByte(), //robotSpeed
134-
request.readByte() //IntegrationTime
135-
);
134+
kP = request.readByte();
135+
kD = request.readByte();
136+
robotSpeedPct = request.readByte();
137+
integrationTimeMillis = request.readByte();
138+
LineFollow::config(kP, kD, robotSpeedPct, integrationTimeMillis);
136139
break;
137140
default:
138141
return false;

0 commit comments

Comments
 (0)