mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-14 04:05:54 +08:00
Fix regression issue : serial bridge was not working since new internal messaging API
This commit is contained in:
parent
fc8c387274
commit
806bc65b81
@ -25,36 +25,29 @@
|
|||||||
#include "esp3d_settings.h"
|
#include "esp3d_settings.h"
|
||||||
|
|
||||||
#if defined(ESP_LOG_FEATURE)
|
#if defined(ESP_LOG_FEATURE)
|
||||||
const char * esp3dclientstr[]={
|
const char *esp3dclientstr[] = {
|
||||||
"no_client",
|
"no_client", "serial", "usb_serial", "stream",
|
||||||
"serial",
|
"telnet", "http", "webui_websocket", "websocket",
|
||||||
"usb_serial",
|
"rendering", "bluetooth", "socket_serial", "echo_serial",
|
||||||
"stream",
|
"serial_bridge", "remote_screen", "mks_serial", "command",
|
||||||
"telnet",
|
"system", "all_clients"};
|
||||||
"http",
|
#define GETCLIENTSTR(id) \
|
||||||
"webui_websocket",
|
static_cast<uint8_t>(id) >= 0 && \
|
||||||
"websocket",
|
static_cast<uint8_t>(id) <= \
|
||||||
"rendering",
|
static_cast<uint8_t>(ESP3DClientType::all_clients) \
|
||||||
"bluetooth",
|
? esp3dclientstr[static_cast<uint8_t>(id)] \
|
||||||
"socket_serial",
|
: "Out of index"
|
||||||
"echo_serial",
|
|
||||||
"serial_bridge",
|
|
||||||
"remote_screen",
|
|
||||||
"mks_serial",
|
|
||||||
"command",
|
|
||||||
"system",
|
|
||||||
"all_clients"
|
|
||||||
};
|
|
||||||
#define GETCLIENTSTR(id) static_cast<uint8_t>(id)>=0 && static_cast<uint8_t>(id)<=static_cast<uint8_t>(ESP3DClientType::all_clients)?esp3dclientstr[static_cast<uint8_t>(id)] :"Out of index"
|
|
||||||
|
|
||||||
const char * esp3dmsgstr[] = {
|
const char *esp3dmsgstr[] = {"head", "core", "tail", "unique"};
|
||||||
"head", "core", "tail", "unique"
|
#define GETMSGTYPESTR(id) \
|
||||||
};
|
static_cast<uint8_t>(id) >= 0 && \
|
||||||
#define GETMSGTYPESTR(id) static_cast<uint8_t>(id)>=0 && static_cast<uint8_t>(id)<=static_cast<uint8_t>(ESP3DMessageType::unique)?esp3dmsgstr[static_cast<uint8_t>(id)] :"Out of index"
|
static_cast<uint8_t>(id) <= \
|
||||||
|
static_cast<uint8_t>(ESP3DMessageType::unique) \
|
||||||
|
? esp3dmsgstr[static_cast<uint8_t>(id)] \
|
||||||
|
: "Out of index"
|
||||||
|
|
||||||
#endif // defined(ESP_LOG_FEATURE)
|
#endif // defined(ESP_LOG_FEATURE)
|
||||||
|
|
||||||
|
|
||||||
#if COMMUNICATION_PROTOCOL == MKS_SERIAL
|
#if COMMUNICATION_PROTOCOL == MKS_SERIAL
|
||||||
#include "../modules/mks/mks_service.h"
|
#include "../modules/mks/mks_service.h"
|
||||||
#endif // COMMUNICATION_PROTOCOL == MKS_SERIAL
|
#endif // COMMUNICATION_PROTOCOL == MKS_SERIAL
|
||||||
@ -596,7 +589,7 @@ void ESP3DCommands::execute_internal_command(int cmd, int cmd_params_pos,
|
|||||||
ESP210(cmd_params_pos, msg);
|
ESP210(cmd_params_pos, msg);
|
||||||
break;
|
break;
|
||||||
#endif // #ifdef SENSOR_DEVICE
|
#endif // #ifdef SENSOR_DEVICE
|
||||||
#if defined (PRINTER_HAS_DISPLAY)
|
#if defined(PRINTER_HAS_DISPLAY)
|
||||||
// Output to printer screen status
|
// Output to printer screen status
|
||||||
//[ESP212]<Text>json=<no> pwd=<user/admin password>
|
//[ESP212]<Text>json=<no> pwd=<user/admin password>
|
||||||
case 212:
|
case 212:
|
||||||
@ -700,7 +693,8 @@ void ESP3DCommands::execute_internal_command(int cmd, int cmd_params_pos,
|
|||||||
ESP600(cmd_params_pos, msg);
|
ESP600(cmd_params_pos, msg);
|
||||||
break;
|
break;
|
||||||
// Set/Get Notification settings
|
// Set/Get Notification settings
|
||||||
//[ESP610]type=<NONE/PUSHOVER/EMAIL/LINE/HOMEASSISTANT> T1=<token1> T2=<token2>
|
//[ESP610]type=<NONE/PUSHOVER/EMAIL/LINE/HOMEASSISTANT> T1=<token1>
|
||||||
|
//T2=<token2>
|
||||||
// TS=<Settings> pwd=<admin password> Get will give type and settings only
|
// TS=<Settings> pwd=<admin password> Get will give type and settings only
|
||||||
// not the protected T1/T2
|
// not the protected T1/T2
|
||||||
case 610:
|
case 610:
|
||||||
@ -887,7 +881,7 @@ bool ESP3DCommands::dispatchSetting(bool json, const char *filter,
|
|||||||
break;
|
break;
|
||||||
default: // String
|
default: // String
|
||||||
if (index == ESP_STA_PASSWORD || index == ESP_AP_PASSWORD ||
|
if (index == ESP_STA_PASSWORD || index == ESP_AP_PASSWORD ||
|
||||||
#if defined (ESP3D_NOTIFICATIONS_FEATURE)
|
#if defined(ESP3D_NOTIFICATIONS_FEATURE)
|
||||||
index == ESP_NOTIFICATION_TOKEN1 ||
|
index == ESP_NOTIFICATION_TOKEN1 ||
|
||||||
index == ESP_NOTIFICATION_TOKEN2 ||
|
index == ESP_NOTIFICATION_TOKEN2 ||
|
||||||
#endif // ESP3D_NOTIFICATIONS_FEATURE
|
#endif // ESP3D_NOTIFICATIONS_FEATURE
|
||||||
@ -997,7 +991,7 @@ bool ESP3DCommands::dispatchAuthenticationError(ESP3DMessage *msg, uint cmdid,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#if defined(HTTP_FEATURE) && defined(AUTHENTICATION_FEATURE)
|
#if defined(HTTP_FEATURE) && defined(AUTHENTICATION_FEATURE)
|
||||||
if (msg->target == ESP3DClientType::http ) {
|
if (msg->target == ESP3DClientType::http) {
|
||||||
msg->authentication_level = ESP3DAuthenticationLevel::not_authenticated;
|
msg->authentication_level = ESP3DAuthenticationLevel::not_authenticated;
|
||||||
}
|
}
|
||||||
#endif // HTTP_FEATURE
|
#endif // HTTP_FEATURE
|
||||||
@ -1115,6 +1109,9 @@ bool ESP3DCommands::formatCommand(char *cmd, size_t len) {
|
|||||||
cmd[sizestr + 1] = 0x0;
|
cmd[sizestr + 1] = 0x0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (sizestr == len && cmd[sizestr-1] == '\n'){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1152,7 +1149,8 @@ void ESP3DCommands::process(ESP3DMessage *msg) {
|
|||||||
execute_internal_command(cmdId, espcmdpos, msg);
|
execute_internal_command(cmdId, espcmdpos, msg);
|
||||||
} else {
|
} else {
|
||||||
esp3d_log("Dispatch command, len %d, from %d(%s) to %d(%s)", msg->size,
|
esp3d_log("Dispatch command, len %d, from %d(%s) to %d(%s)", msg->size,
|
||||||
static_cast<uint8_t>(msg->origin), GETCLIENTSTR(msg->origin), static_cast<uint8_t>(msg->target), GETCLIENTSTR(msg->target));
|
static_cast<uint8_t>(msg->origin), GETCLIENTSTR(msg->origin),
|
||||||
|
static_cast<uint8_t>(msg->target), GETCLIENTSTR(msg->target));
|
||||||
|
|
||||||
// Work around to avoid to dispatch single \n or \r to everyone as it is
|
// Work around to avoid to dispatch single \n or \r to everyone as it is
|
||||||
// part of previous ESP3D command
|
// part of previous ESP3D command
|
||||||
@ -1178,11 +1176,41 @@ bool ESP3DCommands::dispatch(ESP3DMessage *msg, uint8_t *sbuf, size_t len) {
|
|||||||
esp3d_log_e("no msg");
|
esp3d_log_e("no msg");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//check is need \n at the end of the command
|
||||||
|
if (msg->type == ESP3DMessageType::unique ||
|
||||||
|
msg->type == ESP3DMessageType::tail) {
|
||||||
|
esp3d_log("unique or tail message :*%s*", (char *)sbuf);
|
||||||
|
if (!formatCommand((char *)sbuf, len)) {
|
||||||
|
esp3d_log("format command failed");
|
||||||
|
String tmpstr = "";
|
||||||
|
tmpstr.reserve(len + 2);
|
||||||
|
for (uint i = 0; i < len; i++) {
|
||||||
|
tmpstr += char(sbuf[i]);
|
||||||
|
}
|
||||||
|
tmpstr += '\n';
|
||||||
|
esp3d_log("update command success: *%s*", tmpstr.c_str());
|
||||||
|
if (!ESP3DMessageManager::setDataContent(msg, (uint8_t *)tmpstr.c_str(),
|
||||||
|
tmpstr.length())) {
|
||||||
|
esp3d_log_e("set data content failed");
|
||||||
|
ESP3DMessageManager::deleteMsg(msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
esp3d_log("format command success, no need to update");
|
||||||
if (!ESP3DMessageManager::setDataContent(msg, sbuf, len)) {
|
if (!ESP3DMessageManager::setDataContent(msg, sbuf, len)) {
|
||||||
esp3d_log_e("set data content failed");
|
esp3d_log_e("set data content failed");
|
||||||
ESP3DMessageManager::deleteMsg(msg);
|
ESP3DMessageManager::deleteMsg(msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
esp3d_log("not unique or tail message");
|
||||||
|
if (!ESP3DMessageManager::setDataContent(msg, sbuf, len)) {
|
||||||
|
esp3d_log_e("set data content failed");
|
||||||
|
ESP3DMessageManager::deleteMsg(msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return dispatch(msg);
|
return dispatch(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1218,18 +1246,21 @@ bool ESP3DCommands::dispatch(const char *sbuf, ESP3DClientType target,
|
|||||||
ESP3DClientType ESP3DCommands::getOutputClient(bool fromSettings) {
|
ESP3DClientType ESP3DCommands::getOutputClient(bool fromSettings) {
|
||||||
// TODO: add setting for it when necessary
|
// TODO: add setting for it when necessary
|
||||||
(void)fromSettings;
|
(void)fromSettings;
|
||||||
esp3d_log("OutputClient: %d %s", static_cast<uint8_t>(_output_client), GETCLIENTSTR(_output_client));
|
esp3d_log("OutputClient: %d %s", static_cast<uint8_t>(_output_client),
|
||||||
|
GETCLIENTSTR(_output_client));
|
||||||
return _output_client;
|
return _output_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ESP3DCommands::dispatch(ESP3DMessage *msg) {
|
bool ESP3DCommands::dispatch(ESP3DMessage *msg) {
|
||||||
bool sendOk = true;
|
bool sendOk = true;
|
||||||
String tmp;
|
String tmp;
|
||||||
esp3d_log("Dispatch message origin %d(%s) to client %d(%s) , size: %d, type: %d(%s)",
|
esp3d_log(
|
||||||
|
"Dispatch message origin %d(%s) to client %d(%s) , size: %d, type: "
|
||||||
|
"%d(%s)",
|
||||||
static_cast<uint8_t>(msg->origin),
|
static_cast<uint8_t>(msg->origin),
|
||||||
esp3dclientstr[static_cast<uint8_t>(msg->origin)],
|
esp3dclientstr[static_cast<uint8_t>(msg->origin)],
|
||||||
static_cast<uint8_t>(msg->target), GETCLIENTSTR(msg->target),
|
static_cast<uint8_t>(msg->target), GETCLIENTSTR(msg->target), msg->size,
|
||||||
msg->size, static_cast<uint8_t>(msg->type),GETMSGTYPESTR(msg->type));
|
static_cast<uint8_t>(msg->type), GETMSGTYPESTR(msg->type));
|
||||||
esp3d_log("Dispatch message data: %s", (const char *)msg->data);
|
esp3d_log("Dispatch message data: %s", (const char *)msg->data);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
esp3d_log_e("no msg");
|
esp3d_log_e("no msg");
|
||||||
@ -1238,7 +1269,7 @@ bool ESP3DCommands::dispatch(ESP3DMessage *msg) {
|
|||||||
// currently only echo back no test done on success
|
// currently only echo back no test done on success
|
||||||
// TODO check add is successful
|
// TODO check add is successful
|
||||||
switch (msg->target) {
|
switch (msg->target) {
|
||||||
case ESP3DClientType::no_client:
|
case ESP3DClientType::no_client:
|
||||||
esp3d_log("No client message");
|
esp3d_log("No client message");
|
||||||
ESP3DMessageManager::deleteMsg(msg);
|
ESP3DMessageManager::deleteMsg(msg);
|
||||||
break;
|
break;
|
||||||
@ -1256,8 +1287,9 @@ case ESP3DClientType::no_client:
|
|||||||
case ESP3DClientType::echo_serial:
|
case ESP3DClientType::echo_serial:
|
||||||
esp3d_log("Echo serial message");
|
esp3d_log("Echo serial message");
|
||||||
MYSERIAL1.write(msg->data, msg->size);
|
MYSERIAL1.write(msg->data, msg->size);
|
||||||
if (msg->type == ESP3DMessageType::unique || msg->type == ESP3DMessageType::tail) {
|
if (msg->type == ESP3DMessageType::unique ||
|
||||||
if (msg->data[msg->size-1]!='\n'){
|
msg->type == ESP3DMessageType::tail) {
|
||||||
|
if (msg->data[msg->size - 1] != '\n') {
|
||||||
MYSERIAL1.write('\n');
|
MYSERIAL1.write('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1450,7 +1482,8 @@ case ESP3DClientType::no_client:
|
|||||||
#endif // ESP_SERIAL_BRIDGE_OUTPUT
|
#endif // ESP_SERIAL_BRIDGE_OUTPUT
|
||||||
|
|
||||||
#ifdef BLUETOOTH_FEATURE
|
#ifdef BLUETOOTH_FEATURE
|
||||||
if (msg->origin != ESP3DClientType::bluetooth && bt_service.isConnected()) {
|
if (msg->origin != ESP3DClientType::bluetooth &&
|
||||||
|
bt_service.isConnected()) {
|
||||||
if (msg->target == ESP3DClientType::all_clients) {
|
if (msg->target == ESP3DClientType::all_clients) {
|
||||||
// become the reference message
|
// become the reference message
|
||||||
msg->target = ESP3DClientType::bluetooth;
|
msg->target = ESP3DClientType::bluetooth;
|
||||||
@ -1468,7 +1501,8 @@ case ESP3DClientType::no_client:
|
|||||||
#endif // BLUETOOTH_FEATURE
|
#endif // BLUETOOTH_FEATURE
|
||||||
|
|
||||||
#ifdef TELNET_FEATURE
|
#ifdef TELNET_FEATURE
|
||||||
if (msg->origin != ESP3DClientType::telnet && telnet_server.isConnected()) {
|
if (msg->origin != ESP3DClientType::telnet &&
|
||||||
|
telnet_server.isConnected()) {
|
||||||
if (msg->target == ESP3DClientType::all_clients) {
|
if (msg->target == ESP3DClientType::all_clients) {
|
||||||
// become the reference message
|
// become the reference message
|
||||||
msg->target = ESP3DClientType::telnet;
|
msg->target = ESP3DClientType::telnet;
|
||||||
@ -1482,14 +1516,16 @@ case ESP3DClientType::no_client:
|
|||||||
esp3d_log_e("Cannot duplicate message for telnet");
|
esp3d_log_e("Cannot duplicate message for telnet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else{
|
} else {
|
||||||
if (msg->origin != ESP3DClientType::telnet)esp3d_log("Telnet not connected");
|
if (msg->origin != ESP3DClientType::telnet)
|
||||||
|
esp3d_log("Telnet not connected");
|
||||||
}
|
}
|
||||||
#endif // TELNET_FEATURE
|
#endif // TELNET_FEATURE
|
||||||
|
|
||||||
#ifdef HTTP_FEATURE // http cannot be in all client because it depend of any
|
#ifdef HTTP_FEATURE // http cannot be in all client because it depend of any
|
||||||
// connection of the server
|
// connection of the server
|
||||||
if (msg->origin != ESP3DClientType::webui_websocket && websocket_terminal_server.isConnected()) {
|
if (msg->origin != ESP3DClientType::webui_websocket &&
|
||||||
|
websocket_terminal_server.isConnected()) {
|
||||||
if (msg->target == ESP3DClientType::all_clients) {
|
if (msg->target == ESP3DClientType::all_clients) {
|
||||||
// become the reference message
|
// become the reference message
|
||||||
msg->target = ESP3DClientType::webui_websocket;
|
msg->target = ESP3DClientType::webui_websocket;
|
||||||
@ -1504,12 +1540,14 @@ case ESP3DClientType::no_client:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (msg->origin != ESP3DClientType::webui_websocket)esp3d_log("Webui websocket not connected");
|
if (msg->origin != ESP3DClientType::webui_websocket)
|
||||||
|
esp3d_log("Webui websocket not connected");
|
||||||
}
|
}
|
||||||
#endif // HTTP_FEATURE
|
#endif // HTTP_FEATURE
|
||||||
|
|
||||||
#ifdef WS_DATA_FEATURE
|
#ifdef WS_DATA_FEATURE
|
||||||
if (msg->origin != ESP3DClientType::websocket && websocket_data_server.isConnected()) {
|
if (msg->origin != ESP3DClientType::websocket &&
|
||||||
|
websocket_data_server.isConnected()) {
|
||||||
if (msg->target == ESP3DClientType::all_clients) {
|
if (msg->target == ESP3DClientType::all_clients) {
|
||||||
// become the reference message
|
// become the reference message
|
||||||
msg->target = ESP3DClientType::websocket;
|
msg->target = ESP3DClientType::websocket;
|
||||||
@ -1524,7 +1562,8 @@ case ESP3DClientType::no_client:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (msg->origin != ESP3DClientType::websocket)esp3d_log("Websocket not connected");
|
if (msg->origin != ESP3DClientType::websocket)
|
||||||
|
esp3d_log("Websocket not connected");
|
||||||
}
|
}
|
||||||
#endif // WS_DATA_FEATURE
|
#endif // WS_DATA_FEATURE
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#define _VERSION_ESP3D_H
|
#define _VERSION_ESP3D_H
|
||||||
|
|
||||||
// version and sources location
|
// version and sources location
|
||||||
#define FW_VERSION "3.0.0.a232"
|
#define FW_VERSION "3.0.0.a233"
|
||||||
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
|
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
|
||||||
|
|
||||||
#endif //_VERSION_ESP3D_H
|
#endif //_VERSION_ESP3D_H
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "../../core/esp3d_commands.h"
|
#include "../../core/esp3d_commands.h"
|
||||||
#include "../../core/esp3d_settings.h"
|
#include "../../core/esp3d_settings.h"
|
||||||
#include "../../core/esp3d_string.h"
|
#include "../../core/esp3d_string.h"
|
||||||
|
|
||||||
#include "serial_service.h"
|
#include "serial_service.h"
|
||||||
|
|
||||||
#if COMMUNICATION_PROTOCOL == MKS_SERIAL
|
#if COMMUNICATION_PROTOCOL == MKS_SERIAL
|
||||||
@ -64,9 +63,9 @@ ESP3DSerialService serial_bridge_service = ESP3DSerialService(BRIDGE_SERIAL);
|
|||||||
TaskHandle_t _hserialtask = nullptr;
|
TaskHandle_t _hserialtask = nullptr;
|
||||||
#endif // ARDUINO_ARCH_ESP32
|
#endif // ARDUINO_ARCH_ESP32
|
||||||
|
|
||||||
const uint32_t SupportedBaudList[] = {9600, 19200, 38400, 57600,
|
const uint32_t SupportedBaudList[] = {9600, 19200, 38400, 57600, 74880,
|
||||||
74880, 115200, 230400, 250000,
|
115200, 230400, 250000, 500000, 921600,
|
||||||
500000, 921600, 1000000, 1958400, 2000000};
|
1000000, 1958400, 2000000};
|
||||||
const size_t SupportedBaudListSize = sizeof(SupportedBaudList) / sizeof(long);
|
const size_t SupportedBaudListSize = sizeof(SupportedBaudList) / sizeof(long);
|
||||||
|
|
||||||
#define TIMEOUT_SERIAL_FLUSH 1500
|
#define TIMEOUT_SERIAL_FLUSH 1500
|
||||||
@ -107,8 +106,18 @@ ESP3DSerialService::~ESP3DSerialService() { end(); }
|
|||||||
// dedicated serial task
|
// dedicated serial task
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && defined(SERIAL_INDEPENDANT_TASK)
|
#if defined(ARDUINO_ARCH_ESP32) && defined(SERIAL_INDEPENDANT_TASK)
|
||||||
void ESP3DSerialTaskfn(void *parameter) {
|
void ESP3DSerialTaskfn(void *parameter) {
|
||||||
|
uint8_t id = *((uint8_t *)parameter);
|
||||||
|
if (id == MAIN_SERIAL) {
|
||||||
|
esp3d_log("Serial Task for main serial");
|
||||||
|
} else {
|
||||||
|
esp3d_log("Serial Task for bridge serial");
|
||||||
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
esp3d_serial_service.process();
|
esp3d_serial_service.process();
|
||||||
|
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
|
||||||
|
esp3d_log("Serial Task for bridge serial");
|
||||||
|
serial_bridge_service.process();
|
||||||
|
#endif // ESP_SERIAL_BRIDGE_OUTPUT
|
||||||
ESP3DHal::wait(SERIAL_YIELD); // Yield to other tasks
|
ESP3DHal::wait(SERIAL_YIELD); // Yield to other tasks
|
||||||
}
|
}
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
@ -192,16 +201,16 @@ bool ESP3DSerialService::begin(uint8_t serialIndex) {
|
|||||||
|
|
||||||
#endif // ARDUINO_ARCH_ESP8266
|
#endif // ARDUINO_ARCH_ESP8266
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
Serials[_serialIndex]->begin(br, ESP_SERIAL_PARAM, ESP_RX_PIN, ESP_TX_PIN);
|
Serials[_serialIndex]->begin(br, ESP_SERIAL_PARAM, _rxPin, _txPin);
|
||||||
#if defined(SERIAL_INDEPENDANT_TASK)
|
#if defined(SERIAL_INDEPENDANT_TASK)
|
||||||
// create serial task once
|
// create serial task once
|
||||||
esp3d_log("Serial %d for %d Task creation", _serialIndex, _id);
|
esp3d_log("Serial %d for %d Task creation", _serialIndex, _id);
|
||||||
if (_hserialtask == nullptr && _id == MAIN_SERIAL) {
|
if (_hserialtask == nullptr && (_id == MAIN_SERIAL)) {
|
||||||
xTaskCreatePinnedToCore(
|
xTaskCreatePinnedToCore(
|
||||||
ESP3DSerialTaskfn, /* Task function. */
|
ESP3DSerialTaskfn, /* Task function. */
|
||||||
"ESP3D Serial Task", /* name of task. */
|
"ESP3D Serial Task", /* name of task. */
|
||||||
8192, /* Stack size of task */
|
8192, /* Stack size of task */
|
||||||
NULL, /* parameter of the task */
|
&_id, /* parameter of the task = is main or bridge*/
|
||||||
ESP3DSERIAL_RUNNING_PRIORITY, /* priority of the task */
|
ESP3DSERIAL_RUNNING_PRIORITY, /* priority of the task */
|
||||||
&_hserialtask, /* Task handle to keep track of created task */
|
&_hserialtask, /* Task handle to keep track of created task */
|
||||||
ESP3DSERIAL_RUNNING_CORE /* Core to run the task */
|
ESP3DSERIAL_RUNNING_CORE /* Core to run the task */
|
||||||
@ -285,7 +294,7 @@ void ESP3DSerialService::flushbuffer() {
|
|||||||
// dispatch command
|
// dispatch command
|
||||||
if (_started) {
|
if (_started) {
|
||||||
ESP3DMessage *message = ESP3DMessageManager::newMsg(
|
ESP3DMessage *message = ESP3DMessageManager::newMsg(
|
||||||
_origin, ESP3DClientType::all_clients, (uint8_t *)_buffer, _buffer_size,
|
_origin, _id== MAIN_SERIAL?ESP3DClientType::all_clients: esp3d_commands.getOutputClient(), (uint8_t *)_buffer, _buffer_size,
|
||||||
getAuthentication());
|
getAuthentication());
|
||||||
if (message) {
|
if (message) {
|
||||||
// process command
|
// process command
|
||||||
|
Loading…
x
Reference in New Issue
Block a user