dumpsize configurable, =m,=h mqtt fix,

This commit is contained in:
gemu2015 2021-03-02 09:11:08 +01:00
parent 4fb55544bb
commit 56f922a7a7
1 changed files with 24 additions and 5 deletions

View File

@ -822,8 +822,12 @@ uint8_t Serial_peek() {
return meter_ss[num-1]->peek(); return meter_ss[num-1]->peek();
} }
uint8_t sml_logindex; #ifndef SML_DUMP_SIZE
char log_data[128]; #define SML_DUMP_SIZE 128
#endif
uint16_t sml_logindex;
char log_data[SML_DUMP_SIZE];
#define SML_EBUS_SKIP_SYNC_DUMPS #define SML_EBUS_SKIP_SYNC_DUMPS
@ -884,8 +888,8 @@ void Dump2log(void) {
char c = SML_SREAD&0x7f; char c = SML_SREAD&0x7f;
if (c == '\n' || c == '\r') { if (c == '\n' || c == '\r') {
if (sml_logindex > 2) { if (sml_logindex > 2) {
AddLogData(LOG_LEVEL_INFO, log_data);
log_data[sml_logindex] = 0; log_data[sml_logindex] = 0;
AddLogData(LOG_LEVEL_INFO, log_data);
log_data[0] = ':'; log_data[0] = ':';
log_data[1] = ' '; log_data[1] = ' ';
sml_logindex = 2; sml_logindex = 2;
@ -903,6 +907,7 @@ void Dump2log(void) {
while (SML_SAVAILABLE) { while (SML_SAVAILABLE) {
c = SML_SREAD; c = SML_SREAD;
if (c == VBUS_SYNC) { if (c == VBUS_SYNC) {
log_data[sml_logindex] = 0;
AddLogData(LOG_LEVEL_INFO, log_data); AddLogData(LOG_LEVEL_INFO, log_data);
log_data[0] = ':'; log_data[0] = ':';
log_data[1] = ' '; log_data[1] = ' ';
@ -922,6 +927,7 @@ void Dump2log(void) {
p = SML_SPEAK; p = SML_SPEAK;
if (p != EBUS_SYNC && sml_logindex > 5) { if (p != EBUS_SYNC && sml_logindex > 5) {
// new packet, plot last one // new packet, plot last one
log_data[sml_logindex] = 0;
AddLogData(LOG_LEVEL_INFO, log_data); AddLogData(LOG_LEVEL_INFO, log_data);
strcpy(&log_data[0], ": aa "); strcpy(&log_data[0], ": aa ");
sml_logindex = 5; sml_logindex = 5;
@ -939,6 +945,7 @@ void Dump2log(void) {
while (SML_SAVAILABLE) { while (SML_SAVAILABLE) {
c = SML_SREAD; c = SML_SREAD;
if (c == SML_SYNC) { if (c == SML_SYNC) {
log_data[sml_logindex] = 0;
AddLogData(LOG_LEVEL_INFO, log_data); AddLogData(LOG_LEVEL_INFO, log_data);
log_data[0] = ':'; log_data[0] = ':';
log_data[1] = ' '; log_data[1] = ' ';
@ -962,6 +969,7 @@ void Dump2log(void) {
} }
} }
if (sml_logindex > 2) { if (sml_logindex > 2) {
log_data[sml_logindex] = 0;
AddLogData(LOG_LEVEL_INFO, log_data); AddLogData(LOG_LEVEL_INFO, log_data);
} }
} }
@ -1472,6 +1480,7 @@ void SML_Decode(uint8_t index) {
double fac = CharToDouble((char*)mp); double fac = CharToDouble((char*)mp);
meter_vars[vindex] /= fac; meter_vars[vindex] /= fac;
SML_Immediate_MQTT((const char*)mp, vindex, mindex); SML_Immediate_MQTT((const char*)mp, vindex, mindex);
dvalid[vindex] = 1;
// get sfac // get sfac
} else if (*mp=='d') { } else if (*mp=='d') {
// calc deltas d ind 10 (eg every 10 secs) // calc deltas d ind 10 (eg every 10 secs)
@ -1489,7 +1498,16 @@ void SML_Decode(uint8_t index) {
dtimes[dindex] = millis(); dtimes[dindex] = millis();
double vdiff = meter_vars[ind - 1] - dvalues[dindex]; double vdiff = meter_vars[ind - 1] - dvalues[dindex];
dvalues[dindex] = meter_vars[ind - 1]; dvalues[dindex] = meter_vars[ind - 1];
meter_vars[vindex] = (double)360000.0 * vdiff / ((double)dtime / 10000.0); double dres = (double)360000.0 * vdiff / ((double)dtime / 10000.0);
#ifdef USE_SML_MEDIAN_FILTER
if (meter_desc_p[mindex].flag & 16) {
meter_vars[vindex] = sml_median(&sml_mf[vindex], dres);
} else {
meter_vars[vindex] = dres;
}
#else
meter_vars[vindex] = dres;
#endif
mp=strchr(mp,'@'); mp=strchr(mp,'@');
if (mp) { if (mp) {
@ -1499,6 +1517,7 @@ void SML_Decode(uint8_t index) {
SML_Immediate_MQTT((const char*)mp, vindex, mindex); SML_Immediate_MQTT((const char*)mp, vindex, mindex);
} }
} }
dvalid[vindex] = 1;
dindex++; dindex++;
} }
} else if (*mp == 'h') { } else if (*mp == 'h') {
@ -1731,6 +1750,7 @@ void SML_Decode(uint8_t index) {
} }
if (found) { if (found) {
// matches, get value // matches, get value
dvalid[vindex] = 1;
mp++; mp++;
#ifdef ED300L #ifdef ED300L
g_mindex=mindex; g_mindex=mindex;
@ -1838,7 +1858,6 @@ void SML_Decode(uint8_t index) {
SML_Immediate_MQTT((const char*)mp, vindex, mindex); SML_Immediate_MQTT((const char*)mp, vindex, mindex);
} }
} }
dvalid[vindex] = 1;
//AddLog(LOG_LEVEL_INFO, PSTR("set valid in line %d"), vindex); //AddLog(LOG_LEVEL_INFO, PSTR("set valid in line %d"), vindex);
} }
nextsect: nextsect: