Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/js/msp.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ var MSP = {
// message received, store dataview
this.dataView = new DataView(this.message_buffer, 0, this.message_length_expected);
} else {
console.log(`code: ${this.code} - crc failed`);
this.packet_error++;
this.crcError = true;
this.dataView = new DataView(new ArrayBuffer(0));
Expand Down
14 changes: 9 additions & 5 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ MspHelper.prototype.process_data = function(dataHandler) {
FC.BF_CONFIG.currentmetertype = data.readU8();
FC.BF_CONFIG.batterycapacity = data.readU16();
} else {
var offset = 0;
FC.CURRENT_METER_CONFIGS = [];
var current_meter_count = data.readU8();
for (let i = 0; i < current_meter_count; i++) {
Expand Down Expand Up @@ -1618,13 +1617,16 @@ MspHelper.prototype.process_data = function(dataHandler) {
break;
}
}
} else {
console.log(`code: ${code} - crc failed`);
}

// trigger callbacks, cleanup/remove callback after trigger
for (let i = dataHandler.callbacks.length - 1; i >= 0; i--) { // itterating in reverse because we use .splice which modifies array length
if (dataHandler.callbacks[i].code == code) {
for (let i = dataHandler.callbacks.length - 1; i >= 0; i--) { // iterating in reverse because we use .splice which modifies array length
if (dataHandler.callbacks[i]?.code === code) {
// save callback reference
var callback = dataHandler.callbacks[i].callback;
var callbackOnError = dataHandler.callbacks[i].callbackOnError;
const callback = dataHandler.callbacks[i].callback;
const callbackOnError = dataHandler.callbacks[i].callbackOnError;

// remove timeout
clearInterval(dataHandler.callbacks[i].timer);
Expand All @@ -1634,6 +1636,8 @@ MspHelper.prototype.process_data = function(dataHandler) {
if (!crcError || callbackOnError) {
// fire callback
if (callback) callback({'command': code, 'data': data, 'length': data.byteLength, 'crcError': crcError});
} else {
console.log(`code: ${code} - crc failed. No callback`);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function initializeSerialBackend() {
$('select#baud').hide();
} else if (portName !== '0') {
if (!clicks) {
console.log(`${serial.connectionType}: connecting to: ${portName}`);
console.log(`Connecting to: ${portName}`);
GUI.connecting_to = portName;

// lock port select & baud while we are connecting / connected
Expand Down Expand Up @@ -803,7 +803,7 @@ function reinitialiseConnection(originatorTab, callback) {
if (callback) {
callback();
}
}, 100);
}, 200);
//TODO: Need to work out how to do a proper reconnect here.
// caveat: Timeouts set with `GUI.timeout_add()` are removed on disconnect.
} else {
Expand Down