Browse Source

Make HMS packet diagnostics optional at compile time

Detailed HMS frame-map and retransmission diagnostics were useful while investigating incomplete multi-frame responses from HMS-2000-4T inverters. However, the additional output can overflow the WebSerial buffer and affect responsiveness during normal operation.

Wrap the additional diagnostics with the AHOY_HMS_DIAGNOSTICS compile-time switch. The diagnostics are disabled by default and can be enabled with -DAHOY_HMS_DIAGNOSTICS=1. Normal Ahoy logging and retransmission behavior remain unchanged.
pull/1895/head
123fenix 3 weeks ago
parent
commit
dc3e059399
  1. 10
      src/hm/Communication.h

10
src/hm/Communication.h

@ -242,7 +242,9 @@ class Communication : public CommQueue<> {
break;
case States::CHECK_PACKAGE:
#if AHOY_HMS_DIAGNOSTICS
printFrameMap(q, F("check"));
#endif
uint8_t framnr = 0;
if(0 == mMaxFrameId) {
uint8_t i = 0;
@ -297,7 +299,9 @@ class Communication : public CommQueue<> {
q->setAttempt();
if(*mSerialDebug) {
#if AHOY_HMS_DIAGNOSTICS
printFrameMap(q, F("before retransmit"));
#endif
DPRINT_IVID(DBG_WARN, q->iv->id);
DBGPRINT(F("frame "));
DBGPRINT(String(framnr));
@ -422,6 +426,7 @@ class Communication : public CommQueue<> {
return (ah::crc8(buf, len - 1) == buf[len-1]);
}
#if AHOY_HMS_DIAGNOSTICS
inline void printFrameMap(QueueElement *q, const char *stage) {
if(!*mSerialDebug)
return;
@ -457,6 +462,7 @@ class Communication : public CommQueue<> {
DBGPRINT(F(" retransmit="));
DBGPRINTLN(mIsRetransmit ? F("yes") : F("no"));
}
#endif
inline bool parseFrame(QueueElement *q, packet_t *p) {
uint8_t *frameId = &p->packet[9];
@ -485,6 +491,7 @@ class Communication : public CommQueue<> {
f->len = p->len - 11;
f->rssi = p->rssi;
#if AHOY_HMS_DIAGNOSTICS
if(*mSerialDebug) {
DPRINT_IVID(DBG_INFO, q->iv->id);
DBGPRINT(F("stored frame "));
@ -497,6 +504,7 @@ class Communication : public CommQueue<> {
DBGPRINTLN(String(mMaxFrameId));
printFrameMap(q, F("after RX"));
}
#endif
return true;
}
@ -664,6 +672,7 @@ class Communication : public CommQueue<> {
}
void sendRetransmit(QueueElement *q, uint8_t i) {
#if AHOY_HMS_DIAGNOSTICS
if(*mSerialDebug) {
DPRINT_IVID(DBG_INFO, q->iv->id);
DBGPRINT(F("send retransmit request: frame="));
@ -671,6 +680,7 @@ class Communication : public CommQueue<> {
DBGPRINT(F(" cmd=0x"));
DBGHEXLN(SINGLE_FRAME + i);
}
#endif
mFramesExpected = 1;
q->iv->radio->setExpectedFrames(mFramesExpected);
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (SINGLE_FRAME + i), true);

Loading…
Cancel
Save