Patches: Removed critical delay and reduced the error rate.
This commit is contained in:
parent
2d5ac0b16b
commit
0ebc73ad66
18
RIU/RIU.ino
18
RIU/RIU.ino
@ -77,7 +77,7 @@ void setup() {
|
|||||||
void loop() {
|
void loop() {
|
||||||
if (Serial.available()) {
|
if (Serial.available()) {
|
||||||
String command = Serial.readStringUntil('\n');
|
String command = Serial.readStringUntil('\n');
|
||||||
delay(5); // Small delay to make communication more interesting
|
//delay(5); // Small delay to make communication more interesting
|
||||||
handleCommand(command);
|
handleCommand(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,7 +105,9 @@ void handleCommand(String command) {
|
|||||||
} else if (parts[0] == "RESET_SENSORS" && size == 1) {
|
} else if (parts[0] == "RESET_SENSORS" && size == 1) {
|
||||||
resetSensors();
|
resetSensors();
|
||||||
} else {
|
} else {
|
||||||
Serial.println("ERROR: UNKNOWN COMMAND");
|
Serial.println("ERROR: UNKNOWN COMMAND:\n");
|
||||||
|
// PATCH: Print the unknown command in a new line.
|
||||||
|
Serial.println(parts[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] parts;
|
delete[] parts;
|
||||||
@ -115,8 +117,10 @@ void handleCommand(String command) {
|
|||||||
void handleGetSensor(String command, String sensor) {
|
void handleGetSensor(String command, String sensor) {
|
||||||
|
|
||||||
if (command == "REQUEST") { // request data from the RUI (which will request it from the sensor)
|
if (command == "REQUEST") { // request data from the RUI (which will request it from the sensor)
|
||||||
if (!commState.requestConfirmed && randomFailure(0.1)) {
|
if (!commState.requestConfirmed && randomFailure(0.01)) {
|
||||||
Serial.println("ERROR");
|
// PATCH: Reduce all failure rates by 90%
|
||||||
|
Serial.println("ERROR-01 ");
|
||||||
|
// PATCH: "ERROR" is very generic. Let's call it ERROR-01
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastSensorValue = getRawSensorData(sensor);
|
lastSensorValue = getRawSensorData(sensor);
|
||||||
@ -124,7 +128,8 @@ void handleGetSensor(String command, String sensor) {
|
|||||||
commState.requestConfirmed = true;
|
commState.requestConfirmed = true;
|
||||||
|
|
||||||
} else if (command == "CONFIRM") { // did you request the data from the sensor?
|
} else if (command == "CONFIRM") { // did you request the data from the sensor?
|
||||||
if (!commState.confirmConfirmed && randomFailure(0.1)) {
|
// PATCH: Reduce all failure rates by 90%
|
||||||
|
if (!commState.confirmConfirmed && randomFailure(0.01)) {
|
||||||
Serial.println("FALSE");
|
Serial.println("FALSE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -135,7 +140,8 @@ void handleGetSensor(String command, String sensor) {
|
|||||||
Serial.println("FALSE");
|
Serial.println("FALSE");
|
||||||
}
|
}
|
||||||
} else if (command == "CHECK") { // did you get the data from the sensor?
|
} else if (command == "CHECK") { // did you get the data from the sensor?
|
||||||
if (!commState.checkConfirmed && randomFailure(0.5)) {
|
// PATCH: Reduce all failure rates by 90%
|
||||||
|
if (!commState.checkConfirmed && randomFailure(0.05)) {
|
||||||
Serial.println("FALSE");
|
Serial.println("FALSE");
|
||||||
} else {
|
} else {
|
||||||
if (commState.requestConfirmed) {
|
if (commState.requestConfirmed) {
|
||||||
|
Loading…
Reference in New Issue
Block a user