fix sml dumpmode (#17690)

This commit is contained in:
gemu 2023-01-13 13:23:25 +01:00 committed by GitHub
parent 094f45fe7e
commit 3bddbdc5c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 103 additions and 92 deletions

View File

@ -681,98 +681,109 @@ void dump2log(void) {
} }
} }
} else { } else {
if (type == 'o') { switch (type) {
// obis case 'o':
while (SML_SAVAILABLE) { // obis
char c = SML_SREAD&0x7f; while (SML_SAVAILABLE) {
if (c == '\n' || c == '\r') { char c = SML_SREAD&0x7f;
if (sml_globs.sml_logindex > 2) { if (c == '\n' || c == '\r') {
sml_globs.log_data[sml_globs.sml_logindex] = 0; if (sml_globs.sml_logindex > 2) {
AddLogData(LOG_LEVEL_INFO, sml_globs.log_data); sml_globs.log_data[sml_globs.sml_logindex] = 0;
sml_globs.log_data[0] = ':'; AddLogData(LOG_LEVEL_INFO, sml_globs.log_data);
sml_globs.log_data[1] = ' '; sml_globs.log_data[0] = ':';
sml_globs.sml_logindex = 2; sml_globs.log_data[1] = ' ';
} sml_globs.sml_logindex = 2;
continue; }
} continue;
sml_globs.log_data[sml_globs.sml_logindex] = c; }
if (sml_globs.sml_logindex < SML_DUMP_SIZE - 2) { sml_globs.log_data[sml_globs.sml_logindex] = c;
sml_globs.sml_logindex++; if (sml_globs.sml_logindex < SML_DUMP_SIZE - 2) {
} sml_globs.sml_logindex++;
} }
} else if (type == 'v') { }
// vbus break;
uint8_t c; case 'v':
while (SML_SAVAILABLE) { // vbus
c = SML_SREAD; { uint8_t c;
if (c == VBUS_SYNC) { while (SML_SAVAILABLE) {
sml_globs.log_data[sml_globs.sml_logindex] = 0; c = SML_SREAD;
AddLogData(LOG_LEVEL_INFO, sml_globs.log_data); if (c == VBUS_SYNC) {
sml_globs.log_data[0] = ':'; sml_globs.log_data[sml_globs.sml_logindex] = 0;
sml_globs.log_data[1] = ' '; AddLogData(LOG_LEVEL_INFO, sml_globs.log_data);
sml_globs.sml_logindex = 2; sml_globs.log_data[0] = ':';
} sml_globs.log_data[1] = ' ';
sprintf(&sml_globs.log_data[sml_globs.sml_logindex], "%02x ", c); sml_globs.sml_logindex = 2;
if (sml_globs.sml_logindex < SML_DUMP_SIZE - 7) { }
sml_globs.sml_logindex += 3; sprintf(&sml_globs.log_data[sml_globs.sml_logindex], "%02x ", c);
} if (sml_globs.sml_logindex < SML_DUMP_SIZE - 7) {
} sml_globs.sml_logindex += 3;
} else if (type == 'e') { }
// ebus }
uint8_t c, p; }
while (SML_SAVAILABLE) { break;
c = SML_SREAD; case 'e':
if (c == EBUS_SYNC) { // ebus
p = SML_SPEAK; { uint8_t c, p;
if (p != EBUS_SYNC && sml_globs.sml_logindex > 5) { while (SML_SAVAILABLE) {
// new packet, plot last one c = SML_SREAD;
sml_globs.log_data[sml_globs.sml_logindex] = 0; if (c == EBUS_SYNC) {
AddLogData(LOG_LEVEL_INFO, sml_globs.log_data); p = SML_SPEAK;
strcpy(&sml_globs.log_data[0], ": aa "); if (p != EBUS_SYNC && sml_globs.sml_logindex > 5) {
sml_globs.sml_logindex = 5; // new packet, plot last one
} sml_globs.log_data[sml_globs.sml_logindex] = 0;
continue; AddLogData(LOG_LEVEL_INFO, sml_globs.log_data);
} strcpy(&sml_globs.log_data[0], ": aa ");
sprintf(&sml_globs.log_data[sml_globs.sml_logindex], "%02x ", c); sml_globs.sml_logindex = 5;
if (sml_globs.sml_logindex < SML_DUMP_SIZE - 7) { }
sml_globs.sml_logindex += 3; continue;
} }
} sprintf(&sml_globs.log_data[sml_globs.sml_logindex], "%02x ", c);
} else if (type == 's') { if (sml_globs.sml_logindex < SML_DUMP_SIZE - 7) {
// sml sml_globs.sml_logindex += 3;
uint8_t c; }
while (SML_SAVAILABLE) { }
c = SML_SREAD; }
if (c == SML_SYNC) { break;
sml_globs.log_data[0] = ':'; case 's':
sml_globs.log_data[1] = ' '; // sml
sml_globs.sml_logindex = 2; { uint8_t c;
} while (SML_SAVAILABLE) {
sprintf(&sml_globs.log_data[sml_globs.sml_logindex], "%02x ", c); c = SML_SREAD;
if (sml_globs.sml_logindex < SML_DUMP_SIZE - 7) { if (c == SML_SYNC) {
sml_globs.sml_logindex += 3; sml_globs.log_data[sml_globs.sml_logindex] = 0;
} AddLogData(LOG_LEVEL_INFO, sml_globs.log_data);
} sml_globs.log_data[0] = ':';
} else { sml_globs.log_data[1] = ' ';
// raw dump sml_globs.sml_logindex = 2;
d_lastms = millis(); }
sml_globs.log_data[0] = ':'; sprintf(&sml_globs.log_data[sml_globs.sml_logindex], "%02x ", c);
sml_globs.log_data[1] = ' '; if (sml_globs.sml_logindex < SML_DUMP_SIZE - 7) {
sml_globs.sml_logindex = 2; sml_globs.sml_logindex += 3;
while ((millis() - d_lastms) < 40) { }
while (SML_SAVAILABLE) { }
sprintf(&sml_globs.log_data[sml_globs.sml_logindex], "%02x ", SML_SREAD); }
if (sml_globs.sml_logindex < SML_DUMP_SIZE - 7) { break;
sml_globs.sml_logindex += 3; default:
} else { // raw dump
break; d_lastms = millis();
} sml_globs.log_data[0] = ':';
} sml_globs.log_data[1] = ' ';
} sml_globs.sml_logindex = 2;
if (sml_globs.sml_logindex > 2) { while ((millis() - d_lastms) < 40) {
sml_globs.log_data[sml_globs.sml_logindex] = 0; while (SML_SAVAILABLE) {
AddLogData(LOG_LEVEL_INFO, sml_globs.log_data); sprintf(&sml_globs.log_data[sml_globs.sml_logindex], "%02x ", SML_SREAD);
} if (sml_globs.sml_logindex < SML_DUMP_SIZE - 7) {
sml_globs.sml_logindex += 3;
} else {
break;
}
}
}
if (sml_globs.sml_logindex > 2) {
sml_globs.log_data[sml_globs.sml_logindex] = 0;
AddLogData(LOG_LEVEL_INFO, sml_globs.log_data);
}
break;
} }
} }
} }