Fixed checksum
Fixed a bug when requesting negative speed in the checksum calculation due to data type.
This commit is contained in:
parent
9fdb6d75f5
commit
249d93932e
|
@ -92,7 +92,7 @@ void Receive()
|
||||||
// Check for new data availability in the Serial buffer
|
// Check for new data availability in the Serial buffer
|
||||||
if (HoverSerial.available()) {
|
if (HoverSerial.available()) {
|
||||||
incomingByte = HoverSerial.read(); // Read the incoming byte
|
incomingByte = HoverSerial.read(); // Read the incoming byte
|
||||||
bufStartFrame = ((uint16_t)(incomingBytePrev) << 8) + incomingByte; // Construct the start marker
|
bufStartFrame = ((uint16_t)(incomingBytePrev) << 8) + incomingByte; // Construct the start frame
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
|
@ -118,8 +118,8 @@ void Receive()
|
||||||
// Check if we reached the end of the package
|
// Check if we reached the end of the package
|
||||||
if (idx == sizeof(SerialFeedback)) {
|
if (idx == sizeof(SerialFeedback)) {
|
||||||
uint16_t checksum;
|
uint16_t checksum;
|
||||||
checksum = NewFeedback.start ^ NewFeedback.cmd1 ^ NewFeedback.cmd2 ^ NewFeedback.speedR ^ NewFeedback.speedL
|
checksum = (uint16_t)(NewFeedback.start ^ NewFeedback.cmd1 ^ NewFeedback.cmd2 ^ NewFeedback.speedR ^ NewFeedback.speedL
|
||||||
^ NewFeedback.speedR_meas ^ NewFeedback.speedL_meas ^ NewFeedback.batVoltage ^ NewFeedback.boardTemp;
|
^ NewFeedback.speedR_meas ^ NewFeedback.speedL_meas ^ NewFeedback.batVoltage ^ NewFeedback.boardTemp);
|
||||||
|
|
||||||
// Check validity of the new data
|
// Check validity of the new data
|
||||||
if (NewFeedback.start == START_FRAME && checksum == NewFeedback.checksum) {
|
if (NewFeedback.start == START_FRAME && checksum == NewFeedback.checksum) {
|
||||||
|
|
Loading…
Reference in New Issue