From 181617aa819fc69c3ecded364ca38c919d3283aa Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 12 Jun 2022 09:45:55 +0200 Subject: [PATCH] NMT: Show debugging for IDLE frames Suppress repeated IDLE frame --- src/nmt/nmt.c | 14 +++++++++++--- src/nmt/nmt.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/nmt/nmt.c b/src/nmt/nmt.c index 5385593..eb424a8 100644 --- a/src/nmt/nmt.c +++ b/src/nmt/nmt.c @@ -1627,7 +1627,7 @@ const char *nmt_get_frame(nmt_t *nmt) { frame_t frame; const char *bits; - int debug = 1; + int last_frame_idle, debug = 1; memset(&frame, 0, sizeof(frame)); @@ -1681,13 +1681,18 @@ const char *nmt_get_frame(nmt_t *nmt) break; } + last_frame_idle = nmt->tx_last_frame_idle; + nmt->tx_last_frame_idle = 0; + /* no encoding debug for certain (idle) frames */ switch(frame.mt) { case NMT_MESSAGE_1a: case NMT_MESSAGE_4: case NMT_MESSAGE_1b: case NMT_MESSAGE_30: - debug = 0; + if (last_frame_idle) + debug = 0; + nmt->tx_last_frame_idle = 1; break; default: break; @@ -1699,7 +1704,10 @@ const char *nmt_get_frame(nmt_t *nmt) bits = encode_frame(nmt->sysinfo.system, &frame, debug); - PDEBUG_CHAN(DNMT, DEBUG_DEBUG, "Sending frame %s.\n", nmt_frame_name(frame.mt)); + if (debug) + PDEBUG_CHAN(DNMT, DEBUG_DEBUG, "Sending frame %s.\n", nmt_frame_name(frame.mt)); + if (debug && nmt->tx_last_frame_idle) + PDEBUG_CHAN(DNMT, DEBUG_DEBUG, "Subsequent IDLE frames are not show, to prevent flooding the output.\n"); return bits; } diff --git a/src/nmt/nmt.h b/src/nmt/nmt.h index 06d0629..b8707aa 100644 --- a/src/nmt/nmt.h +++ b/src/nmt/nmt.h @@ -131,6 +131,7 @@ struct nmt { char tx_frame[166]; /* carries bits of one frame to transmit */ int tx_frame_length; int tx_frame_pos; + int tx_last_frame_idle; /* indicator to prevent debugging all idle frames */ /* DMS/SMS states */ dms_t dms; /* DMS states */