mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 11:59:51 +03:00
Compute and verify the LTM checksum
This commit is contained in:
parent
742176d7eb
commit
16b097cf8e
1 changed files with 15 additions and 1 deletions
|
@ -154,7 +154,7 @@ helper.ltmDecoder = (function () {
|
|||
privateScope.receiverIndex = 0;
|
||||
privateScope.serialBuffer = [];
|
||||
privateScope.protocolState = LTM_STATE_MSGTYPE;
|
||||
console.log('privateScope.protocolState: LTM_STATE_MSGTYPE', 'will expext frame ' + privateScope.frameType, 'expected length: ' + privateScope.frameLength);
|
||||
console.log('protocolState: LTM_STATE_MSGTYPE', 'will expext frame ' + privateScope.frameType, 'expected length: ' + privateScope.frameLength);
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -167,6 +167,20 @@ helper.ltmDecoder = (function () {
|
|||
/*
|
||||
* If YES, check checksum and execute data processing
|
||||
*/
|
||||
|
||||
let checksum = 0;
|
||||
for (let i = 0; i < privateScope.serialBuffer.length; i++) {
|
||||
checksum ^= privateScope.serialBuffer[i];
|
||||
}
|
||||
|
||||
if (checksum != data) {
|
||||
console.log('LTM checksum error, frame type: ' + privateScope.frameType + ' rejected');
|
||||
privateScope.protocolState = LTM_STATE_IDLE;
|
||||
privateScope.serialBuffer = [];
|
||||
privateScope.receiverIndex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (privateScope.frameType == 'A') {
|
||||
TELEMETRY.pitch = privateScope.readInt(0);
|
||||
TELEMETRY.roll = privateScope.readInt(2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue