mirror of
https://github.com/luc-github/ESP3D.git
synced 2026-03-10 18:06:48 +01:00
Grbl grblHAL better support for realtime commands (#1064)
* Add a realtime command detector * Move `\r` as printable char and not replaced as `\n` * Refactorize Serial service code to avoid redondant code between esp32 and esp8266 * Implement isrealtimeCommand check for serial and centralize function in string helper * Add new type message : realtimecmd * Update simulator to handle commands and realtime commands * Add simple serial test tool * Generate error if use HAS_DISPLAY with grbl/grblHAL * Implement isRealTimeCommand for BT client * Simplify BT push2buffer code * Implement support for realtimecommand in telnet * Implement isRealTimeCommand on websocket RX * Simplify push2RXbuffer for websocket * Implement isRealTimeCommand for USB serial * Bump version
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "../include/esp3d_config.h"
|
||||
#include "esp3d_settings.h"
|
||||
|
||||
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
|
||||
#include "../modules/network/netconfig.h"
|
||||
@@ -174,16 +175,16 @@ const char* esp3d_string::urlEncode(const char* s) {
|
||||
static String encoded;
|
||||
encoded = "";
|
||||
char temp[4];
|
||||
for (int i = 0; i < strlen(s); i++) {
|
||||
temp[0] =s[i];
|
||||
if (temp[0] == 32) { //space
|
||||
for (size_t i = 0; i < strlen(s); i++) {
|
||||
temp[0] = s[i];
|
||||
if (temp[0] == 32) { // space
|
||||
encoded.concat('+');
|
||||
} else if ((temp[0] >= 48 && temp[0] <= 57) /*0-9*/
|
||||
|| (temp[0] >= 65 && temp[0] <= 90) /*A-Z*/
|
||||
|| (temp[0] >= 97 && temp[0] <= 122) /*a-z*/
|
||||
} else if ((temp[0] >= 48 && temp[0] <= 57) /*0-9*/
|
||||
|| (temp[0] >= 65 && temp[0] <= 90) /*A-Z*/
|
||||
|| (temp[0] >= 97 && temp[0] <= 122) /*a-z*/
|
||||
) {
|
||||
encoded.concat(temp[0]);
|
||||
} else { //character needs encoding
|
||||
} else { // character needs encoding
|
||||
snprintf(temp, 4, "%%%02X", temp[0]);
|
||||
encoded.concat(temp);
|
||||
}
|
||||
@@ -208,7 +209,7 @@ const char* esp3d_string::formatBytes(uint64_t bytes) {
|
||||
|
||||
bool esp3d_string::isPrintableChar(char ch) {
|
||||
int c = static_cast<int>(ch);
|
||||
if (c == 9 || (c >= 32 && c <= 126) || c >= 128) {
|
||||
if (c == '\t' || c == '\r' || (c >= ' ' && c <= '~') || c >= 128) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -254,7 +255,7 @@ const char* esp3d_string::formatDuration(uint64_t duration) {
|
||||
display = true;
|
||||
}
|
||||
if (hours > 0 || display) {
|
||||
result+= String(hours) + "h ";
|
||||
result += String(hours) + "h ";
|
||||
display = true;
|
||||
}
|
||||
if (minutes > 0 || display) {
|
||||
@@ -264,4 +265,21 @@ const char* esp3d_string::formatDuration(uint64_t duration) {
|
||||
result += String(seconds) + "s";
|
||||
|
||||
return result.c_str();
|
||||
}
|
||||
|
||||
bool esp3d_string::isRealTimeCommand(char c) {
|
||||
if (ESP3DSettings::GetFirmwareTarget() == GRBL ||
|
||||
ESP3DSettings::GetFirmwareTarget() == GRBLHAL) {
|
||||
// Standard characters
|
||||
if (c == '?' || c == '!' || c == '~' || c == 0x18) { // 0x18 is ^X
|
||||
return true;
|
||||
}
|
||||
|
||||
// Range >= 0x80 et <= 0xA4
|
||||
const unsigned char uc = static_cast<unsigned char>(c);
|
||||
if (uc >= 0x80 && uc <= 0xA4) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user