splitting MSP and CLI integration, new serial api
parent
834345a80c
commit
c0937ddbd4
|
@ -72,8 +72,6 @@ function MSP_char_read(readInfo) {
|
|||
var data = new Uint8Array(readInfo.data);
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (CLI_active != true) {
|
||||
// Standard "GUI" MSP handling
|
||||
switch (MSP.state) {
|
||||
case 0: // sync char 1
|
||||
if (data[i] == 36) { // $
|
||||
|
@ -142,10 +140,6 @@ function MSP_char_read(readInfo) {
|
|||
MSP.state = 0;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// CLI Enabled (Terminal "style" handling)
|
||||
handle_CLI(data[i]);
|
||||
}
|
||||
|
||||
char_counter++;
|
||||
}
|
||||
|
|
|
@ -288,7 +288,11 @@ function onClosed(result) {
|
|||
}
|
||||
|
||||
function read_serial(info) {
|
||||
if (!CLI_active) {
|
||||
MSP_char_read(info);
|
||||
} else {
|
||||
handle_CLI(info);
|
||||
}
|
||||
}
|
||||
|
||||
function port_usage() {
|
||||
|
|
26
tabs/cli.js
26
tabs/cli.js
|
@ -118,16 +118,17 @@ function send_slowly(out_arr, i, timeout_needle) {
|
|||
*/
|
||||
|
||||
var sequence_elements = 0;
|
||||
function handle_CLI(readInfo) {
|
||||
var data = new Uint8Array(readInfo.data);
|
||||
var text = "";
|
||||
|
||||
function handle_CLI(data) {
|
||||
if (data == 27 || sequence_elements > 0) { // ESC + other
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (data[i] == 27 || sequence_elements > 0) { // ESC + other
|
||||
sequence_elements++;
|
||||
|
||||
// delete previous space
|
||||
if (sequence_elements == 1) {
|
||||
var content_string = $('.tab-cli .window .wrapper').html();
|
||||
var new_string = content_string.substring(0, content_string.length -1);
|
||||
$('.tab-cli .window .wrapper').html(new_string);
|
||||
text = text.substring(0, text.length -1);
|
||||
}
|
||||
|
||||
// Reset
|
||||
|
@ -137,20 +138,25 @@ function handle_CLI(data) {
|
|||
}
|
||||
|
||||
if (sequence_elements == 0) {
|
||||
switch (data) {
|
||||
switch (data[i]) {
|
||||
case 10: // line feed
|
||||
if (GUI.operating_system == "Windows" || GUI.operating_system == "Linux" || GUI.operating_system == "UNIX") {
|
||||
$('.tab-cli .window .wrapper').append("<br />");
|
||||
text += "<br />";
|
||||
}
|
||||
break;
|
||||
case 13: // carriage return
|
||||
if (GUI.operating_system == "MacOS") {
|
||||
$('.tab-cli .window .wrapper').append("<br />");
|
||||
text += "<br />";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$('.tab-cli .window .wrapper').append(String.fromCharCode(data));
|
||||
$('.tab-cli .window').scrollTop($('.tab-cli .window .wrapper').height());
|
||||
text += String.fromCharCode(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
char_counter++;
|
||||
}
|
||||
|
||||
$('.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…
Reference in New Issue