mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
initial work on pass through mode for ReadError
This commit is contained in:
parent
f649418fdf
commit
cb5bcf9c0a
3 changed files with 71 additions and 45 deletions
|
@ -36,6 +36,7 @@ $(document).ready(function() {
|
||||||
MSP.disconnect_cleanup();
|
MSP.disconnect_cleanup();
|
||||||
PortUsage.reset();
|
PortUsage.reset();
|
||||||
configuration_received = false; // reset valid config received variable (used to block tabs while not connected properly)
|
configuration_received = false; // reset valid config received variable (used to block tabs while not connected properly)
|
||||||
|
MSP_pass_through = false;
|
||||||
|
|
||||||
// unlock port select & baud
|
// unlock port select & baud
|
||||||
$('div#port-picker #port').prop('disabled', false);
|
$('div#port-picker #port').prop('disabled', false);
|
||||||
|
@ -125,34 +126,39 @@ function onOpen(openInfo) {
|
||||||
|
|
||||||
serial.onReceive.addListener(read_serial);
|
serial.onReceive.addListener(read_serial);
|
||||||
|
|
||||||
// disconnect after 10 seconds with error if we don't get IDENT data
|
if (!MSP_pass_through) {
|
||||||
GUI.timeout_add('connecting', function() {
|
// disconnect after 10 seconds with error if we don't get IDENT data
|
||||||
if (!configuration_received) {
|
GUI.timeout_add('connecting', function() {
|
||||||
GUI.log(chrome.i18n.getMessage('noConfigurationReceived'));
|
if (!configuration_received) {
|
||||||
|
GUI.log(chrome.i18n.getMessage('noConfigurationReceived'));
|
||||||
|
|
||||||
$('div#port-picker a.connect').click(); // disconnect
|
|
||||||
}
|
|
||||||
}, 10000);
|
|
||||||
|
|
||||||
// request configuration data
|
|
||||||
MSP.send_message(MSP_codes.MSP_UID, false, false, function() {
|
|
||||||
GUI.log(chrome.i18n.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)]));
|
|
||||||
MSP.send_message(MSP_codes.MSP_IDENT, false, false, function() {
|
|
||||||
GUI.timeout_remove('connecting'); // kill connecting timer
|
|
||||||
|
|
||||||
GUI.log(chrome.i18n.getMessage('firmwareVersion', [CONFIG.version]));
|
|
||||||
|
|
||||||
if (CONFIG.version >= firmware_version_accepted) {
|
|
||||||
configuration_received = true;
|
|
||||||
|
|
||||||
$('div#port-picker a.connect').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
|
||||||
$('#tabs li a:first').click();
|
|
||||||
} else {
|
|
||||||
GUI.log(chrome.i18n.getMessage('firmwareVersionNotSupported', [firmware_version_accepted]));
|
|
||||||
$('div#port-picker a.connect').click(); // disconnect
|
$('div#port-picker a.connect').click(); // disconnect
|
||||||
}
|
}
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
|
// request configuration data
|
||||||
|
MSP.send_message(MSP_codes.MSP_UID, false, false, function() {
|
||||||
|
GUI.log(chrome.i18n.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)]));
|
||||||
|
MSP.send_message(MSP_codes.MSP_IDENT, false, false, function() {
|
||||||
|
GUI.timeout_remove('connecting'); // kill connecting timer
|
||||||
|
|
||||||
|
GUI.log(chrome.i18n.getMessage('firmwareVersion', [CONFIG.version]));
|
||||||
|
|
||||||
|
if (CONFIG.version >= firmware_version_accepted) {
|
||||||
|
configuration_received = true;
|
||||||
|
|
||||||
|
$('div#port-picker a.connect').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
||||||
|
$('#tabs li a:first').click();
|
||||||
|
} else {
|
||||||
|
GUI.log(chrome.i18n.getMessage('firmwareVersionNotSupported', [firmware_version_accepted]));
|
||||||
|
$('div#port-picker a.connect').click(); // disconnect
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
|
$('div#port-picker a.connect').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
||||||
|
GUI.log('Connection opened in <strong>pass-through</strong> mode');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('Failed to open serial port');
|
console.log('Failed to open serial port');
|
||||||
GUI.log(chrome.i18n.getMessage('serialPortOpenFail'));
|
GUI.log(chrome.i18n.getMessage('serialPortOpenFail'));
|
||||||
|
@ -177,10 +183,12 @@ function onClosed(result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_serial(info) {
|
function read_serial(info) {
|
||||||
if (!CLI_active) {
|
if (!CLI_active && !MSP_pass_through) {
|
||||||
MSP.read(info);
|
MSP.read(info);
|
||||||
} else {
|
} else if (CLI_active) {
|
||||||
handle_CLI(info);
|
handle_CLI(info);
|
||||||
|
} else if (MSP_pass_through) { // needs to be verified, might be removed after pass_through is 100% deployed
|
||||||
|
MSP.read(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
main.js
8
main.js
|
@ -54,10 +54,11 @@ $(document).ready(function() {
|
||||||
if ($(this).parent().hasClass('active') == false) { // only initialize when the tab isn't already active
|
if ($(this).parent().hasClass('active') == false) { // only initialize when the tab isn't already active
|
||||||
var self = this;
|
var self = this;
|
||||||
var index = $(self).parent().index();
|
var index = $(self).parent().index();
|
||||||
|
var tab = $(self).parent().prop('class');
|
||||||
|
|
||||||
// if there is no active connection, return
|
// if there is no active connection, return
|
||||||
if (configuration_received == false) {
|
if (!configuration_received && tab != 'tab_logging') {
|
||||||
GUI.log('You need to connect before you can view any of the tabs', 'red');
|
GUI.log('You need to <strong>connect</strong> before you can view any of the tabs');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,9 +66,6 @@ $(document).ready(function() {
|
||||||
// disable previously active tab highlight
|
// disable previously active tab highlight
|
||||||
$('li', tabs).removeClass('active');
|
$('li', tabs).removeClass('active');
|
||||||
|
|
||||||
// get tab class name (there should be only one class listed)
|
|
||||||
var tab = $(self).parent().prop('class');
|
|
||||||
|
|
||||||
// Highlight selected tab
|
// Highlight selected tab
|
||||||
$(self).parent().addClass('active');
|
$(self).parent().addClass('active');
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,34 @@
|
||||||
|
var MSP_pass_through = false;
|
||||||
|
|
||||||
function tab_initialize_logging() {
|
function tab_initialize_logging() {
|
||||||
ga_tracker.sendAppView('Logging');
|
ga_tracker.sendAppView('Logging');
|
||||||
GUI.active_tab = 'logging';
|
GUI.active_tab = 'logging';
|
||||||
|
|
||||||
var requested_properties = [];
|
var requested_properties = [];
|
||||||
|
|
||||||
MSP.send_message(MSP_codes.MSP_RC, false, false, get_motor_data);
|
if (configuration_received) {
|
||||||
|
MSP.send_message(MSP_codes.MSP_RC, false, false, get_motor_data);
|
||||||
|
|
||||||
function get_motor_data() {
|
function get_motor_data() {
|
||||||
MSP.send_message(MSP_codes.MSP_MOTOR, false, false, load_html);
|
MSP.send_message(MSP_codes.MSP_MOTOR, false, false, load_html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function load_html() {
|
||||||
|
$('#content').load("./tabs/logging.html", process_html);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MSP_pass_through = true;
|
||||||
|
|
||||||
|
// we will initialize RC.channels array and MOTOR_DATA array manually
|
||||||
|
RC.active_channels = 8;
|
||||||
|
for (var i = 0; i < RC.active_channels; i++) {
|
||||||
|
RC.channels[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < 8; i++) {
|
||||||
|
MOTOR_DATA[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
function load_html() {
|
|
||||||
$('#content').load("./tabs/logging.html", process_html);
|
$('#content').load("./tabs/logging.html", process_html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +54,7 @@ function tab_initialize_logging() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (requested_properties.length) {
|
if (requested_properties.length) {
|
||||||
// print header for the
|
// print header for the csv file
|
||||||
print_head();
|
print_head();
|
||||||
|
|
||||||
function poll_data() {
|
function poll_data() {
|
||||||
|
@ -44,16 +62,18 @@ function tab_initialize_logging() {
|
||||||
crunch_data();
|
crunch_data();
|
||||||
|
|
||||||
// request new
|
// request new
|
||||||
for (var i = 0; i < requested_properties.length; i++) {
|
if (!MSP_pass_through) {
|
||||||
MSP.send_message(MSP_codes[requested_properties[i]]);
|
for (var i = 0; i < requested_properties.length; 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);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue