mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Fix telnet response if seriallog is 0
This commit is contained in:
parent
ea2baee3b8
commit
74757ee7da
@ -2398,6 +2398,10 @@ void SystemBusyDelayExecute(void) {
|
|||||||
*
|
*
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
|
void SetMinimumSeriallog(void) {
|
||||||
|
TasmotaGlobal.seriallog_level = (Settings->seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings->seriallog_level;
|
||||||
|
}
|
||||||
|
|
||||||
void SetTasConlog(uint32_t loglevel) {
|
void SetTasConlog(uint32_t loglevel) {
|
||||||
Settings->seriallog_level = loglevel;
|
Settings->seriallog_level = loglevel;
|
||||||
TasmotaGlobal.seriallog_level = loglevel;
|
TasmotaGlobal.seriallog_level = loglevel;
|
||||||
@ -2608,7 +2612,8 @@ bool GetLog(uint32_t req_loglevel, uint32_t* index_p, char** entry_pp, size_t* l
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t HighestLogLevel(void) {
|
uint32_t HighestLogLevel(void) {
|
||||||
uint32_t highest_loglevel = Settings->seriallog_level;
|
uint32_t highest_loglevel = TasmotaGlobal.seriallog_level;
|
||||||
|
if (Settings->seriallog_level > highest_loglevel) { highest_loglevel = Settings->seriallog_level; }
|
||||||
if (Settings->mqttlog_level > highest_loglevel) { highest_loglevel = Settings->mqttlog_level; }
|
if (Settings->mqttlog_level > highest_loglevel) { highest_loglevel = Settings->mqttlog_level; }
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
if (Settings->weblog_level > highest_loglevel) { highest_loglevel = Settings->weblog_level; }
|
if (Settings->weblog_level > highest_loglevel) { highest_loglevel = Settings->weblog_level; }
|
||||||
@ -2703,11 +2708,15 @@ void AddLogData(uint32_t loglevel, const char* log_data, const char* log_data_pa
|
|||||||
// These calls fail to show initial logging
|
// These calls fail to show initial logging
|
||||||
log_line += 2; // Skip log_buffer_pointer and loglevel
|
log_line += 2; // Skip log_buffer_pointer and loglevel
|
||||||
#ifdef USE_SERIAL_BRIDGE
|
#ifdef USE_SERIAL_BRIDGE
|
||||||
SerialBridgeWrite(log_line, log_data_len);
|
if (loglevel <= TasmotaGlobal.seriallog_level) {
|
||||||
|
SerialBridgeWrite(log_line, log_data_len);
|
||||||
|
}
|
||||||
#endif // USE_SERIAL_BRIDGE
|
#endif // USE_SERIAL_BRIDGE
|
||||||
#ifdef USE_TELNET
|
#ifdef USE_TELNET
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
TelnetWrite(log_line, log_data_len); // This uses too much heap on ESP8266
|
if (loglevel <= TasmotaGlobal.seriallog_level) {
|
||||||
|
TelnetWrite(log_line, log_data_len); // This uses too much heap on ESP8266
|
||||||
|
}
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
#endif // USE_TELNET
|
#endif // USE_TELNET
|
||||||
|
|
||||||
|
@ -1870,7 +1870,7 @@ void SerialInput(void)
|
|||||||
|
|
||||||
if (!Settings->flag.mqtt_serial && (TasmotaGlobal.serial_in_byte == '\n')) { // CMND_SERIALSEND and CMND_SERIALLOG
|
if (!Settings->flag.mqtt_serial && (TasmotaGlobal.serial_in_byte == '\n')) { // CMND_SERIALSEND and CMND_SERIALLOG
|
||||||
TasmotaGlobal.serial_in_buffer[TasmotaGlobal.serial_in_byte_counter] = 0; // Serial data completed
|
TasmotaGlobal.serial_in_buffer[TasmotaGlobal.serial_in_byte_counter] = 0; // Serial data completed
|
||||||
TasmotaGlobal.seriallog_level = (Settings->seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings->seriallog_level;
|
SetMinimumSeriallog();
|
||||||
if (serial_buffer_overrun) {
|
if (serial_buffer_overrun) {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "Serial buffer overrun"));
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "Serial buffer overrun"));
|
||||||
} else {
|
} else {
|
||||||
@ -1937,7 +1937,7 @@ void TasConsoleInput(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (console_in_byte == '\n') {
|
else if (console_in_byte == '\n') {
|
||||||
TasmotaGlobal.seriallog_level = (Settings->seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings->seriallog_level;
|
SetMinimumSeriallog();
|
||||||
if (console_buffer_overrun) {
|
if (console_buffer_overrun) {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "USB buffer overrun"));
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "USB buffer overrun"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -156,7 +156,7 @@ void SerialBridgeLoop(void) {
|
|||||||
}
|
}
|
||||||
else if (serial_in_byte == '\n') {
|
else if (serial_in_byte == '\n') {
|
||||||
serial_bridge_buffer[SBridge.in_byte_counter] = 0; // Serial data completed
|
serial_bridge_buffer[SBridge.in_byte_counter] = 0; // Serial data completed
|
||||||
TasmotaGlobal.seriallog_level = (Settings->seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings->seriallog_level;
|
SetMinimumSeriallog();
|
||||||
if (serial_bridge_overrun) {
|
if (serial_bridge_overrun) {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "SSerial buffer overrun"));
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "SSerial buffer overrun"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,6 +122,18 @@ void TelnetWrite(char *line, uint32_t len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TelnetGetLog(void) {
|
||||||
|
uint32_t index = Telnet.log_index; // Dump log buffer
|
||||||
|
char* line;
|
||||||
|
size_t len;
|
||||||
|
bool any_line = false;
|
||||||
|
while (GetLog(TasmotaGlobal.seriallog_level, &index, &line, &len)) {
|
||||||
|
any_line = true;
|
||||||
|
TelnetWrite(line, len -1);
|
||||||
|
}
|
||||||
|
Telnet.log_index = index;
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
|
|
||||||
void TelnetLoop(void) {
|
void TelnetLoop(void) {
|
||||||
@ -143,54 +155,28 @@ void TelnetLoop(void) {
|
|||||||
}
|
}
|
||||||
Telnet.client = new_client;
|
Telnet.client = new_client;
|
||||||
if (Telnet.client) {
|
if (Telnet.client) {
|
||||||
|
SetMinimumSeriallog();
|
||||||
Telnet.client.printf("Tasmota %s %s (%s) %s\r\n", NetworkHostname(), TasmotaGlobal.version, GetBuildDateAndTime().c_str(), GetDeviceHardware().c_str());
|
Telnet.client.printf("Tasmota %s %s (%s) %s\r\n", NetworkHostname(), TasmotaGlobal.version, GetBuildDateAndTime().c_str(), GetDeviceHardware().c_str());
|
||||||
Telnet.prompt = 3;
|
Telnet.prompt = 3; // Print linefeed for non-requested data and use log color
|
||||||
#ifdef ESP32
|
Telnet.log_index = 1; // Dump start of log buffer for restart messages
|
||||||
uint32_t index = 1;
|
TelnetGetLog();
|
||||||
char* line;
|
Telnet.prompt = 1; // Print prompt after requested data and use response color
|
||||||
size_t len;
|
|
||||||
while (GetLog(Settings->seriallog_level, &index, &line, &len)) {
|
|
||||||
TelnetWrite(line, len -1);
|
|
||||||
}
|
|
||||||
Telnet.prompt = 0;
|
|
||||||
#else // ESP8266
|
|
||||||
Telnet.log_index = 0; // Dump start of log buffer for restart messages
|
|
||||||
#endif // ESP32 - ESP8266
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Telnet.client) {
|
if (Telnet.client) {
|
||||||
// Output latest log buffer data
|
// Output latest data
|
||||||
#ifdef ESP32
|
#ifdef ESP8266
|
||||||
if (0 == Telnet.prompt) {
|
TelnetGetLog(); // As heap is low on ESP8266 it uses log output
|
||||||
|
#endif
|
||||||
|
if (1 == Telnet.prompt) {
|
||||||
TelnetWriteColor(Telnet.color[0]);
|
TelnetWriteColor(Telnet.color[0]);
|
||||||
Telnet.client.printf("%s:# ", NetworkHostname());
|
Telnet.client.printf("%s:# ", NetworkHostname());
|
||||||
TelnetWriteColor(0);
|
TelnetWriteColor(0);
|
||||||
Telnet.prompt = 3; // Print linefeed for non-requested data
|
Telnet.prompt = 3; // Print linefeed for non-requested data and use log color
|
||||||
while (Telnet.client.available()) { Telnet.client.read(); } // Flush input
|
while (Telnet.client.available()) { Telnet.client.read(); } // Flush input
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else // ESP8266
|
|
||||||
uint32_t index = Telnet.log_index; // Dump log buffer
|
|
||||||
char* line;
|
|
||||||
size_t len;
|
|
||||||
bool any_line = false;
|
|
||||||
while (GetLog(Settings->seriallog_level, &index, &line, &len)) {
|
|
||||||
any_line = true;
|
|
||||||
TelnetWrite(line, len -1);
|
|
||||||
}
|
|
||||||
if (any_line) {
|
|
||||||
if ((0 == Telnet.log_index) || (Telnet.prompt != 2)) {
|
|
||||||
TelnetWriteColor(Telnet.color[0]);
|
|
||||||
Telnet.client.printf("%s:# ", NetworkHostname());
|
|
||||||
TelnetWriteColor(0);
|
|
||||||
Telnet.prompt = 3; // Print linefeed for non-requested data
|
|
||||||
while (Telnet.client.available()) { Telnet.client.read(); } // Flush input
|
|
||||||
}
|
|
||||||
Telnet.log_index = index;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif // ESP32 - ESP8266
|
|
||||||
|
|
||||||
// Input keyboard data
|
// Input keyboard data
|
||||||
while (Telnet.client.available()) {
|
while (Telnet.client.available()) {
|
||||||
@ -202,10 +188,10 @@ void TelnetLoop(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (in_byte == '\n') {
|
else if (in_byte == '\n') {
|
||||||
Telnet.buffer[Telnet.in_byte_counter] = 0; // Telnet data completed
|
|
||||||
TasmotaGlobal.seriallog_level = (Settings->seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings->seriallog_level;
|
|
||||||
Telnet.client.write("\r"); // Move cursor to begin of line (needed for non-buffered input)
|
Telnet.client.write("\r"); // Move cursor to begin of line (needed for non-buffered input)
|
||||||
Telnet.prompt = 1; // Do not print linefeed for requested data and use response color
|
Telnet.buffer[Telnet.in_byte_counter] = 0; // Telnet data completed
|
||||||
|
Telnet.prompt = 1; // Print prompt after requested data and use response color
|
||||||
|
SetMinimumSeriallog();
|
||||||
if (Telnet.in_byte_counter >= Telnet.buffer_size) {
|
if (Telnet.in_byte_counter >= Telnet.buffer_size) {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TELNET "Buffer overrun"));
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TELNET "Buffer overrun"));
|
||||||
} else {
|
} else {
|
||||||
@ -219,9 +205,6 @@ void TelnetLoop(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Telnet.in_byte_counter = 0;
|
Telnet.in_byte_counter = 0;
|
||||||
#ifdef ESP32
|
|
||||||
Telnet.prompt = 0; // Print prompt
|
|
||||||
#endif // ESP32
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user