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