initial work on pass through mode for ReadError
parent
f649418fdf
commit
cb5bcf9c0a
|
@ -36,6 +36,7 @@ $(document).ready(function() {
|
|||
MSP.disconnect_cleanup();
|
||||
PortUsage.reset();
|
||||
configuration_received = false; // reset valid config received variable (used to block tabs while not connected properly)
|
||||
MSP_pass_through = false;
|
||||
|
||||
// unlock port select & baud
|
||||
$('div#port-picker #port').prop('disabled', false);
|
||||
|
@ -125,34 +126,39 @@ function onOpen(openInfo) {
|
|||
|
||||
serial.onReceive.addListener(read_serial);
|
||||
|
||||
// disconnect after 10 seconds with error if we don't get IDENT data
|
||||
GUI.timeout_add('connecting', function() {
|
||||
if (!configuration_received) {
|
||||
GUI.log(chrome.i18n.getMessage('noConfigurationReceived'));
|
||||
if (!MSP_pass_through) {
|
||||
// disconnect after 10 seconds with error if we don't get IDENT data
|
||||
GUI.timeout_add('connecting', function() {
|
||||
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
|
||||
}
|
||||
}, 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 {
|
||||
console.log('Failed to open serial port');
|
||||
GUI.log(chrome.i18n.getMessage('serialPortOpenFail'));
|
||||
|
@ -177,10 +183,12 @@ function onClosed(result) {
|
|||
}
|
||||
|
||||
function read_serial(info) {
|
||||
if (!CLI_active) {
|
||||
if (!CLI_active && !MSP_pass_through) {
|
||||
MSP.read(info);
|
||||
} else {
|
||||
} else if (CLI_active) {
|
||||
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
|
||||
var self = this;
|
||||
var index = $(self).parent().index();
|
||||
var tab = $(self).parent().prop('class');
|
||||
|
||||
// if there is no active connection, return
|
||||
if (configuration_received == false) {
|
||||
GUI.log('You need to connect before you can view any of the tabs', 'red');
|
||||
if (!configuration_received && tab != 'tab_logging') {
|
||||
GUI.log('You need to <strong>connect</strong> before you can view any of the tabs');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -65,9 +66,6 @@ $(document).ready(function() {
|
|||
// disable previously active tab highlight
|
||||
$('li', tabs).removeClass('active');
|
||||
|
||||
// get tab class name (there should be only one class listed)
|
||||
var tab = $(self).parent().prop('class');
|
||||
|
||||
// Highlight selected tab
|
||||
$(self).parent().addClass('active');
|
||||
|
||||
|
|
|
@ -1,16 +1,34 @@
|
|||
var MSP_pass_through = false;
|
||||
|
||||
function tab_initialize_logging() {
|
||||
ga_tracker.sendAppView('Logging');
|
||||
GUI.active_tab = 'logging';
|
||||
|
||||
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() {
|
||||
MSP.send_message(MSP_codes.MSP_MOTOR, false, false, load_html);
|
||||
}
|
||||
function get_motor_data() {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -36,7 +54,7 @@ function tab_initialize_logging() {
|
|||
});
|
||||
|
||||
if (requested_properties.length) {
|
||||
// print header for the
|
||||
// print header for the csv file
|
||||
print_head();
|
||||
|
||||
function poll_data() {
|
||||
|
@ -44,16 +62,18 @@ function tab_initialize_logging() {
|
|||
crunch_data();
|
||||
|
||||
// request new
|
||||
for (var i = 0; i < requested_properties.length; i++) {
|
||||
MSP.send_message(MSP_codes[requested_properties[i]]);
|
||||
if (!MSP_pass_through) {
|
||||
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
|
||||
if (i < requested_properties.length -1) {
|
||||
MSP.send_message(requested_properties[i]);
|
||||
} else {
|
||||
MSP.send_message(requested_properties[i], false, false, poll_data);
|
||||
/* this approach could be used if we want to utilize request time compensation
|
||||
if (i < requested_properties.length -1) {
|
||||
MSP.send_message(requested_properties[i]);
|
||||
} else {
|
||||
MSP.send_message(requested_properties[i], false, false, poll_data);
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue