different approach to serial API logging
parent
58877b0bd2
commit
aa49e8c375
12
js/serial.js
12
js/serial.js
|
@ -6,6 +6,11 @@ var serial = {
|
|||
|
||||
chrome.serial.connect(path, options, function(connectionInfo) {
|
||||
self.connectionId = connectionInfo.connectionId;
|
||||
|
||||
if (connectionInfo.connectionId > 0) {
|
||||
console.log('SERIAL: Connection opened with ID: ' + connectionInfo.connectionId + ', Baud: ' + connectionInfo.bitrate);
|
||||
}
|
||||
|
||||
callback(connectionInfo);
|
||||
});
|
||||
},
|
||||
|
@ -13,7 +18,14 @@ var serial = {
|
|||
var self = this;
|
||||
|
||||
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;
|
||||
|
||||
callback(result);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -214,8 +214,6 @@ function onOpen(openInfo) {
|
|||
// reset connecting_to
|
||||
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
|
||||
chrome.storage.local.get('last_used_port', function(result) {
|
||||
if (typeof result.last_used_port != 'undefined') {
|
||||
|
@ -280,10 +278,7 @@ function onClosed(result) {
|
|||
sensor_status(sensors_detected = 0); // reset active sensor indicators
|
||||
$('#tabs > ul li').removeClass('active'); // de-select any selected tabs
|
||||
tab_initialize_default();
|
||||
|
||||
console.log('Connection closed successfully.');
|
||||
} else { // Something went wrong
|
||||
console.log('There was an error that happened during "connection-close" procedure.');
|
||||
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')) {
|
||||
serial.connect(selected_port, {bitrate: baud}, function(openInfo) {
|
||||
if (openInfo.connectionId > 0) {
|
||||
console.log('Connection was opened with ID: ' + openInfo.connectionId + ' Baud: ' + baud);
|
||||
console.log('Sending ascii "R" to reboot');
|
||||
|
||||
// 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() {
|
||||
serial.disconnect(function(result) {
|
||||
if (result) {
|
||||
console.log('Connection closed successfully.');
|
||||
|
||||
if (result) {
|
||||
serial.connect(selected_port, {bitrate: flashing_bitrate, parityBit: 'even', stopBits: 'one'}, function(openInfo) {
|
||||
if (openInfo.connectionId > 0) {
|
||||
console.log('Connection was opened with ID: ' + openInfo.connectionId + ' Baud: ' + flashing_bitrate);
|
||||
|
||||
if (openInfo.connectionId > 0) {
|
||||
self.initialize();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('There was an error that happened during "connection-close" procedure');
|
||||
|
||||
GUI.connect_lock = false;
|
||||
}
|
||||
});
|
||||
|
@ -114,9 +107,7 @@ STM32_protocol.prototype.connect = function(hex) {
|
|||
});
|
||||
} else {
|
||||
serial.connect(selected_port, {bitrate: flashing_bitrate, parityBit: 'even', stopBits: 'one'}, function(openInfo) {
|
||||
if (openInfo.connectionId > 0) {
|
||||
console.log('Connection was opened with ID: ' + openInfo.connectionId + ' Baud: ' + flashing_bitrate);
|
||||
|
||||
if (openInfo.connectionId > 0) {
|
||||
// we are connected, disabling connect button in the UI
|
||||
GUI.connect_lock = true;
|
||||
|
||||
|
@ -591,9 +582,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
|
|||
// close connection
|
||||
serial.disconnect(function(result) {
|
||||
if (result) { // All went as expected
|
||||
console.log('Connection closed successfully.');
|
||||
} else { // Something went wrong
|
||||
console.log('There was an error that happened during "connection-close" procedure');
|
||||
}
|
||||
|
||||
// unlocking connect button
|
||||
|
|
Loading…
Reference in New Issue