du.ino process() incorrectly parses servo messages
rwaldron opened this issue · 0 comments
rwaldron commented
To narrow this down, I added the following to handleServo
:
Serial.println(atoi(val));
Serial.println(atoi(aux));
An example of the output:
1331739178315 duino receive 98A00265
1331739178315 duino receive ss
1331739178315 duino receive got signal
1331739178315 duino receive 26 /* atoi(val) */
1331739178315 duino receive 5 /* atoi(aux) */
If the message being parsed is 98A00265
, then the expected values are:
1331739178315 duino receive 2 /* atoi(val) */
1331739178315 duino receive 65 /* atoi(aux) */
Otherwise, this block:
} else if (atoi(val) == 2) {
Serial.println("writing to servo");
Serial.println(atoi(aux));
servo.write(atoi(aux));
}
...While never be entered.
The issue is here:
strncpy(val, messageBuffer + 4, 3);
val[3] = '\0';
strncpy(aux, messageBuffer + 7, 3);
aux[3] = '\0';
By changing this to:
strncpy(val, messageBuffer + 4, 2);
val[3] = '\0';
strncpy(aux, messageBuffer + 6, 3);
aux[3] = '\0';
... The servo values are written.
I will test this against all of the other modules + hardware and submit a patch when complete.