mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 20:10:11 +03:00
drop junk in input buffer before entering CLI
this could use some polishing but i think it will do for now close #21
This commit is contained in:
parent
c0937ddbd4
commit
39075c06ab
3 changed files with 42 additions and 32 deletions
|
@ -229,6 +229,7 @@ GUI_control.prototype.tab_switch_cleanup = function(callback) {
|
|||
// we could probably implement this someday
|
||||
GUI.timeout_add('waiting_for_bootup', function() {
|
||||
CLI_active = false;
|
||||
CLI_valid = false;
|
||||
|
||||
if (callback) callback();
|
||||
}, 5000); // if we dont allow enough time to reboot, CRC of "first" command sent will fail, keep an eye for this one
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var configuration_received = false;
|
||||
var CLI_active = false;
|
||||
var CLI_valid = false;
|
||||
|
||||
var CONFIG = {
|
||||
version: 0,
|
||||
|
|
18
tabs/cli.js
18
tabs/cli.js
|
@ -72,11 +72,6 @@ function tab_initialize_cli() {
|
|||
// give input element user focus
|
||||
$('.tab-cli textarea').focus();
|
||||
|
||||
// if user clicks inside the console window, input element gets re-focused
|
||||
$('.tab-cli .window').click(function() {
|
||||
$('.tab-cli textarea').focus();
|
||||
});
|
||||
|
||||
$('.tab-cli .copy').click(function() {
|
||||
var text = $('.tab-cli .window .wrapper').html();
|
||||
text = text.replace(/<br\s*\/?>/mg,"\n"); // replacing br tags with \n to keep some of the formating
|
||||
|
@ -118,11 +113,13 @@ function send_slowly(out_arr, i, timeout_needle) {
|
|||
*/
|
||||
|
||||
var sequence_elements = 0;
|
||||
var CLI_validate_text = "";
|
||||
function handle_CLI(readInfo) {
|
||||
var data = new Uint8Array(readInfo.data);
|
||||
var text = "";
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (CLI_valid) {
|
||||
if (data[i] == 27 || sequence_elements > 0) { // ESC + other
|
||||
sequence_elements++;
|
||||
|
||||
|
@ -153,10 +150,21 @@ function handle_CLI(readInfo) {
|
|||
text += String.fromCharCode(data[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// try to catch part of valid CLI enter message
|
||||
CLI_validate_text += String.fromCharCode(data[i]);
|
||||
}
|
||||
|
||||
char_counter++;
|
||||
}
|
||||
|
||||
if (!CLI_valid && CLI_validate_text.indexOf('CLI') != -1) {
|
||||
CLI_valid = true;
|
||||
CLI_validate_text = "";
|
||||
|
||||
text = "Entering CLI Mode, type 'exit' to return, or 'help'<br /><br /># ";
|
||||
}
|
||||
|
||||
$('.tab-cli .window .wrapper').append(text);
|
||||
$('.tab-cli .window').scrollTop($('.tab-cli .window .wrapper').height()); // there seems to be some sort of initial rendering glitch in 33+, why?
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue