mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-20 06:45:12 +03:00
add error message for not being connected
This commit is contained in:
parent
19de1e8040
commit
8dfec796ee
2 changed files with 61 additions and 54 deletions
|
@ -493,6 +493,9 @@
|
||||||
"loggingBack": {
|
"loggingBack": {
|
||||||
"message": "Leave Logging / Disconnect"
|
"message": "Leave Logging / Disconnect"
|
||||||
},
|
},
|
||||||
|
"loggingErrorNotConnected": {
|
||||||
|
"message": "You need to <strong>connect</strong> first"
|
||||||
|
},
|
||||||
"loggingErrorLogFile": {
|
"loggingErrorLogFile": {
|
||||||
"message": "Please select log file"
|
"message": "Please select log file"
|
||||||
},
|
},
|
||||||
|
|
112
tabs/logging.js
112
tabs/logging.js
|
@ -40,75 +40,79 @@ function tab_initialize_logging() {
|
||||||
$('a.log_file').click(prepare_file);
|
$('a.log_file').click(prepare_file);
|
||||||
|
|
||||||
$('a.logging').click(function() {
|
$('a.logging').click(function() {
|
||||||
if (fileEntry != null) {
|
if (GUI.connected_to) {
|
||||||
var clicks = $(this).data('clicks');
|
if (fileEntry != null) {
|
||||||
|
var clicks = $(this).data('clicks');
|
||||||
|
|
||||||
if (!clicks) {
|
if (!clicks) {
|
||||||
// reset some variables before start
|
// reset some variables before start
|
||||||
samples = 0;
|
samples = 0;
|
||||||
log_buffer = [];
|
log_buffer = [];
|
||||||
requested_properties = [];
|
requested_properties = [];
|
||||||
|
|
||||||
$('.properties input:checked').each(function() {
|
$('.properties input:checked').each(function() {
|
||||||
requested_properties.push($(this).prop('name'));
|
requested_properties.push($(this).prop('name'));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (requested_properties.length) {
|
if (requested_properties.length) {
|
||||||
// print header for the csv file
|
// print header for the csv file
|
||||||
print_head();
|
print_head();
|
||||||
|
|
||||||
function poll_data() {
|
function poll_data() {
|
||||||
// save current
|
// save current
|
||||||
crunch_data();
|
crunch_data();
|
||||||
|
|
||||||
// request new
|
// request new
|
||||||
if (!MSP_pass_through) {
|
if (!MSP_pass_through) {
|
||||||
for (var i = 0; i < requested_properties.length; i++) {
|
for (var i = 0; i < requested_properties.length; i++) {
|
||||||
MSP.send_message(MSP_codes[requested_properties[i]]);
|
MSP.send_message(MSP_codes[requested_properties[i]]);
|
||||||
|
|
||||||
/* this approach could be used if we want to utilize request time compensation
|
/* this approach could be used if we want to utilize request time compensation
|
||||||
if (i < requested_properties.length -1) {
|
if (i < requested_properties.length -1) {
|
||||||
MSP.send_message(requested_properties[i]);
|
MSP.send_message(requested_properties[i]);
|
||||||
} else {
|
} else {
|
||||||
MSP.send_message(requested_properties[i], false, false, poll_data);
|
MSP.send_message(requested_properties[i], false, false, poll_data);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GUI.interval_add('log_data_pull', poll_data, parseInt($('select.speed').val()), true); // refresh rate goes here
|
||||||
|
GUI.interval_add('flush_data', function() {
|
||||||
|
if (log_buffer.length) { // only execute when there is actual data to write
|
||||||
|
if (fileWriter.readyState == 0 || fileWriter.readyState == 2) {
|
||||||
|
append_to_file(log_buffer.join('\n'));
|
||||||
|
|
||||||
|
$('.samples').text(samples += log_buffer.length);
|
||||||
|
$('.size').text(chrome.i18n.getMessage('loggingKB', [(fileWriter.length / 1024).toFixed(2)]));
|
||||||
|
|
||||||
|
log_buffer = [];
|
||||||
|
} else {
|
||||||
|
console.log('IO having trouble keeping up with the data flow');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
$('.speed').prop('disabled', true);
|
||||||
|
$(this).text(chrome.i18n.getMessage('loggingStop'));
|
||||||
|
$(this).data("clicks", !clicks);
|
||||||
|
} else {
|
||||||
|
GUI.log(chrome.i18n.getMessage('loggingErrorOneProperty'));
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.interval_add('log_data_pull', poll_data, parseInt($('select.speed').val()), true); // refresh rate goes here
|
|
||||||
GUI.interval_add('flush_data', function() {
|
|
||||||
if (log_buffer.length) { // only execute when there is actual data to write
|
|
||||||
if (fileWriter.readyState == 0 || fileWriter.readyState == 2) {
|
|
||||||
append_to_file(log_buffer.join('\n'));
|
|
||||||
|
|
||||||
$('.samples').text(samples += log_buffer.length);
|
|
||||||
$('.size').text(chrome.i18n.getMessage('loggingKB', [(fileWriter.length / 1024).toFixed(2)]));
|
|
||||||
|
|
||||||
log_buffer = [];
|
|
||||||
} else {
|
|
||||||
console.log('IO having trouble keeping up with the data flow');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
$('.speed').prop('disabled', true);
|
|
||||||
$(this).text(chrome.i18n.getMessage('loggingStop'));
|
|
||||||
$(this).data("clicks", !clicks);
|
|
||||||
} else {
|
} else {
|
||||||
GUI.log(chrome.i18n.getMessage('loggingErrorOneProperty'));
|
GUI.interval_remove('log_data_pull');
|
||||||
|
GUI.interval_remove('flush_data');
|
||||||
|
|
||||||
|
$('.speed').prop('disabled', false);
|
||||||
|
$(this).text(chrome.i18n.getMessage('loggingStart'));
|
||||||
|
$(this).data("clicks", !clicks);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GUI.interval_remove('log_data_pull');
|
GUI.log(chrome.i18n.getMessage('loggingErrorLogFile'));
|
||||||
GUI.interval_remove('flush_data');
|
|
||||||
|
|
||||||
$('.speed').prop('disabled', false);
|
|
||||||
$(this).text(chrome.i18n.getMessage('loggingStart'));
|
|
||||||
$(this).data("clicks", !clicks);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GUI.log(chrome.i18n.getMessage('loggingErrorLogFile'));
|
GUI.log(chrome.i18n.getMessage('loggingErrorNotConnected'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue