mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Prep removal of global log_data providing re-entry
This commit is contained in:
parent
b1b20c53b4
commit
61c559e748
@ -821,40 +821,41 @@ uint8_t sml_logindex;
|
|||||||
|
|
||||||
void Dump2log(void) {
|
void Dump2log(void) {
|
||||||
|
|
||||||
int16_t index=0,hcnt=0;
|
int16_t index=0,hcnt=0;
|
||||||
uint32_t d_lastms;
|
uint32_t d_lastms;
|
||||||
uint8_t dchars[16];
|
uint8_t dchars[16];
|
||||||
|
char log_data[LOGSZ]; // May be a lot smaller...
|
||||||
|
|
||||||
//if (!SML_SAVAILABLE) return;
|
//if (!SML_SAVAILABLE) return;
|
||||||
|
|
||||||
if (dump2log&8) {
|
if (dump2log&8) {
|
||||||
// combo mode
|
// combo mode
|
||||||
while (SML_SAVAILABLE) {
|
while (SML_SAVAILABLE) {
|
||||||
TasmotaGlobal.log_data[index]=':';
|
log_data[index]=':';
|
||||||
index++;
|
index++;
|
||||||
TasmotaGlobal.log_data[index]=' ';
|
log_data[index]=' ';
|
||||||
index++;
|
index++;
|
||||||
d_lastms=millis();
|
d_lastms=millis();
|
||||||
while ((millis()-d_lastms)<40) {
|
while ((millis()-d_lastms)<40) {
|
||||||
if (SML_SAVAILABLE) {
|
if (SML_SAVAILABLE) {
|
||||||
uint8_t c=SML_SREAD;
|
uint8_t c=SML_SREAD;
|
||||||
sprintf(&TasmotaGlobal.log_data[index],"%02x ",c);
|
sprintf(&log_data[index],"%02x ",c);
|
||||||
dchars[hcnt]=c;
|
dchars[hcnt]=c;
|
||||||
index+=3;
|
index+=3;
|
||||||
hcnt++;
|
hcnt++;
|
||||||
if (hcnt>15) {
|
if (hcnt>15) {
|
||||||
// line complete, build asci chars
|
// line complete, build asci chars
|
||||||
TasmotaGlobal.log_data[index]='=';
|
log_data[index]='=';
|
||||||
index++;
|
index++;
|
||||||
TasmotaGlobal.log_data[index]='>';
|
log_data[index]='>';
|
||||||
index++;
|
index++;
|
||||||
TasmotaGlobal.log_data[index]=' ';
|
log_data[index]=' ';
|
||||||
index++;
|
index++;
|
||||||
for (uint8_t ccnt=0; ccnt<16; ccnt++) {
|
for (uint8_t ccnt=0; ccnt<16; ccnt++) {
|
||||||
if (isprint(dchars[ccnt])) {
|
if (isprint(dchars[ccnt])) {
|
||||||
TasmotaGlobal.log_data[index]=dchars[ccnt];
|
log_data[index]=dchars[ccnt];
|
||||||
} else {
|
} else {
|
||||||
TasmotaGlobal.log_data[index]=' ';
|
log_data[index]=' ';
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@ -863,8 +864,8 @@ uint8_t dchars[16];
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index>0) {
|
if (index>0) {
|
||||||
TasmotaGlobal.log_data[index]=0;
|
log_data[index]=0;
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||||
index=0;
|
index=0;
|
||||||
hcnt=0;
|
hcnt=0;
|
||||||
}
|
}
|
||||||
@ -875,24 +876,24 @@ uint8_t dchars[16];
|
|||||||
while (SML_SAVAILABLE) {
|
while (SML_SAVAILABLE) {
|
||||||
char c=SML_SREAD&0x7f;
|
char c=SML_SREAD&0x7f;
|
||||||
if (c=='\n' || c=='\r') {
|
if (c=='\n' || c=='\r') {
|
||||||
TasmotaGlobal.log_data[sml_logindex]=0;
|
log_data[sml_logindex]=0;
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLog(LOG_LEVEL_INFO);
|
||||||
sml_logindex=2;
|
sml_logindex=2;
|
||||||
TasmotaGlobal.log_data[0]=':';
|
log_data[0]=':';
|
||||||
TasmotaGlobal.log_data[1]=' ';
|
log_data[1]=' ';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TasmotaGlobal.log_data[sml_logindex]=c;
|
log_data[sml_logindex]=c;
|
||||||
if (sml_logindex<sizeof(TasmotaGlobal.log_data)-2) {
|
if (sml_logindex<sizeof(log_data)-2) {
|
||||||
sml_logindex++;
|
sml_logindex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//while (SML_SAVAILABLE) {
|
//while (SML_SAVAILABLE) {
|
||||||
index=0;
|
index=0;
|
||||||
TasmotaGlobal.log_data[index]=':';
|
log_data[index]=':';
|
||||||
index++;
|
index++;
|
||||||
TasmotaGlobal.log_data[index]=' ';
|
log_data[index]=' ';
|
||||||
index++;
|
index++;
|
||||||
d_lastms=millis();
|
d_lastms=millis();
|
||||||
while ((millis()-d_lastms)<40) {
|
while ((millis()-d_lastms)<40) {
|
||||||
@ -901,7 +902,7 @@ uint8_t dchars[16];
|
|||||||
if (meter_desc_p[(dump2log&7)-1].type=='e') {
|
if (meter_desc_p[(dump2log&7)-1].type=='e') {
|
||||||
// ebus
|
// ebus
|
||||||
c=SML_SREAD;
|
c=SML_SREAD;
|
||||||
sprintf(&TasmotaGlobal.log_data[index],"%02x ",c);
|
sprintf(&log_data[index],"%02x ",c);
|
||||||
index+=3;
|
index+=3;
|
||||||
if (c==EBUS_SYNC) break;
|
if (c==EBUS_SYNC) break;
|
||||||
} else {
|
} else {
|
||||||
@ -916,14 +917,14 @@ uint8_t dchars[16];
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c=SML_SREAD;
|
c=SML_SREAD;
|
||||||
sprintf(&TasmotaGlobal.log_data[index],"%02x ",c);
|
sprintf(&log_data[index],"%02x ",c);
|
||||||
index+=3;
|
index+=3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index>2) {
|
if (index>2) {
|
||||||
TasmotaGlobal.log_data[index]=0;
|
log_data[index]=0;
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user