mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 11:59:51 +03:00
different approach to serial API logging
This commit is contained in:
parent
58877b0bd2
commit
aa49e8c375
3 changed files with 15 additions and 19 deletions
12
js/serial.js
12
js/serial.js
|
@ -6,6 +6,11 @@ var serial = {
|
||||||
|
|
||||||
chrome.serial.connect(path, options, function(connectionInfo) {
|
chrome.serial.connect(path, options, function(connectionInfo) {
|
||||||
self.connectionId = connectionInfo.connectionId;
|
self.connectionId = connectionInfo.connectionId;
|
||||||
|
|
||||||
|
if (connectionInfo.connectionId > 0) {
|
||||||
|
console.log('SERIAL: Connection opened with ID: ' + connectionInfo.connectionId + ', Baud: ' + connectionInfo.bitrate);
|
||||||
|
}
|
||||||
|
|
||||||
callback(connectionInfo);
|
callback(connectionInfo);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -13,7 +18,14 @@ var serial = {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
chrome.serial.disconnect(this.connectionId, function(result) {
|
chrome.serial.disconnect(this.connectionId, function(result) {
|
||||||
|
if (result) {
|
||||||
|
console.log('SERIAL: Connection with ID: ' + self.connectionId + ' closed');
|
||||||
|
} else {
|
||||||
|
console.log('SERIAL: Failed to close connection with ID: ' + self.connectionId + ' closed');
|
||||||
|
}
|
||||||
|
|
||||||
self.connectionId = -1;
|
self.connectionId = -1;
|
||||||
|
|
||||||
callback(result);
|
callback(result);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -214,8 +214,6 @@ function onOpen(openInfo) {
|
||||||
// reset connecting_to
|
// reset connecting_to
|
||||||
GUI.connecting_to = false;
|
GUI.connecting_to = false;
|
||||||
|
|
||||||
console.log('Connection was opened with ID: ' + openInfo.connectionId + ', Baud: ' + openInfo.bitrate);
|
|
||||||
|
|
||||||
// save selected port with chrome.storage if the port differs
|
// save selected port with chrome.storage if the port differs
|
||||||
chrome.storage.local.get('last_used_port', function(result) {
|
chrome.storage.local.get('last_used_port', function(result) {
|
||||||
if (typeof result.last_used_port != 'undefined') {
|
if (typeof result.last_used_port != 'undefined') {
|
||||||
|
@ -280,10 +278,7 @@ function onClosed(result) {
|
||||||
sensor_status(sensors_detected = 0); // reset active sensor indicators
|
sensor_status(sensors_detected = 0); // reset active sensor indicators
|
||||||
$('#tabs > ul li').removeClass('active'); // de-select any selected tabs
|
$('#tabs > ul li').removeClass('active'); // de-select any selected tabs
|
||||||
tab_initialize_default();
|
tab_initialize_default();
|
||||||
|
|
||||||
console.log('Connection closed successfully.');
|
|
||||||
} else { // Something went wrong
|
} else { // Something went wrong
|
||||||
console.log('There was an error that happened during "connection-close" procedure.');
|
|
||||||
notify('Failed to close serial port', 'red');
|
notify('Failed to close serial port', 'red');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
17
js/stm32.js
17
js/stm32.js
|
@ -83,7 +83,6 @@ STM32_protocol.prototype.connect = function(hex) {
|
||||||
if (!$('input.updating').is(':checked')) {
|
if (!$('input.updating').is(':checked')) {
|
||||||
serial.connect(selected_port, {bitrate: baud}, function(openInfo) {
|
serial.connect(selected_port, {bitrate: baud}, function(openInfo) {
|
||||||
if (openInfo.connectionId > 0) {
|
if (openInfo.connectionId > 0) {
|
||||||
console.log('Connection was opened with ID: ' + openInfo.connectionId + ' Baud: ' + baud);
|
|
||||||
console.log('Sending ascii "R" to reboot');
|
console.log('Sending ascii "R" to reboot');
|
||||||
|
|
||||||
// we are connected, disabling connect button in the UI
|
// we are connected, disabling connect button in the UI
|
||||||
|
@ -93,19 +92,13 @@ STM32_protocol.prototype.connect = function(hex) {
|
||||||
|
|
||||||
GUI.timeout_add('reboot_into_bootloader', function() {
|
GUI.timeout_add('reboot_into_bootloader', function() {
|
||||||
serial.disconnect(function(result) {
|
serial.disconnect(function(result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
console.log('Connection closed successfully.');
|
|
||||||
|
|
||||||
serial.connect(selected_port, {bitrate: flashing_bitrate, parityBit: 'even', stopBits: 'one'}, function(openInfo) {
|
serial.connect(selected_port, {bitrate: flashing_bitrate, parityBit: 'even', stopBits: 'one'}, function(openInfo) {
|
||||||
if (openInfo.connectionId > 0) {
|
if (openInfo.connectionId > 0) {
|
||||||
console.log('Connection was opened with ID: ' + openInfo.connectionId + ' Baud: ' + flashing_bitrate);
|
|
||||||
|
|
||||||
self.initialize();
|
self.initialize();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('There was an error that happened during "connection-close" procedure');
|
|
||||||
|
|
||||||
GUI.connect_lock = false;
|
GUI.connect_lock = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -114,9 +107,7 @@ STM32_protocol.prototype.connect = function(hex) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
serial.connect(selected_port, {bitrate: flashing_bitrate, parityBit: 'even', stopBits: 'one'}, function(openInfo) {
|
serial.connect(selected_port, {bitrate: flashing_bitrate, parityBit: 'even', stopBits: 'one'}, function(openInfo) {
|
||||||
if (openInfo.connectionId > 0) {
|
if (openInfo.connectionId > 0) {
|
||||||
console.log('Connection was opened with ID: ' + openInfo.connectionId + ' Baud: ' + flashing_bitrate);
|
|
||||||
|
|
||||||
// we are connected, disabling connect button in the UI
|
// we are connected, disabling connect button in the UI
|
||||||
GUI.connect_lock = true;
|
GUI.connect_lock = true;
|
||||||
|
|
||||||
|
@ -591,9 +582,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
|
||||||
// close connection
|
// close connection
|
||||||
serial.disconnect(function(result) {
|
serial.disconnect(function(result) {
|
||||||
if (result) { // All went as expected
|
if (result) { // All went as expected
|
||||||
console.log('Connection closed successfully.');
|
|
||||||
} else { // Something went wrong
|
} else { // Something went wrong
|
||||||
console.log('There was an error that happened during "connection-close" procedure');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// unlocking connect button
|
// unlocking connect button
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue