From c5b36af672da9f2c1239d868fab08557acc6e6a3 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Thu, 25 Apr 2024 16:14:59 -0400 Subject: [PATCH] Add .bin loop 'debug mode' on -J; --- include/dsd.h | 1 + src/dsd_main.c | 13 ++++++++++--- src/dsd_ncurses.c | 1 + src/dsd_symbol.c | 8 +++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/dsd.h b/include/dsd.h index c3f5aad..aeb2d4a 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -588,6 +588,7 @@ typedef struct unsigned int debug_audio_errorsR; unsigned int debug_header_errors; unsigned int debug_header_critical_errors; + int debug_mode; //debug misc things // Last dibit read int last_dibit; diff --git a/src/dsd_main.c b/src/dsd_main.c index c387a9403..95c9afe 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -948,6 +948,7 @@ initState (dsd_state * state) state->debug_audio_errorsR = 0; state->debug_header_errors = 0; state->debug_header_critical_errors = 0; + state->debug_mode = 0; state->nxdn_last_ran = -1; state->nxdn_last_rid = 0; @@ -1694,7 +1695,7 @@ main (int argc, char **argv) exitflag = 0; - while ((c = getopt (argc, argv, "yhaepPqs:t:v:z:i:o:d:c:g:n:w:B:C:R:f:m:u:x:A:S:M:G:D:L:V:U:YK:b:H:X:NQ:WrlZTF01:2:345:6:7:89Ek:I:")) != -1) + while ((c = getopt (argc, argv, "yhaepPqs:t:v:z:i:o:d:c:g:n:w:B:C:R:f:m:u:x:A:S:M:G:D:L:V:U:YK:b:H:X:NQ:WrlZTF01:2:345:6:7:89Ek:I:J")) != -1) { opterr = 0; switch (c) @@ -1708,8 +1709,8 @@ main (int argc, char **argv) opts.call_alert = 1; break; - //Free'd up switches include: I, J, j, n, O, v, y - //all numerals have reclaimed, except for 4 and 0,1 (rc4 enforcement and single key) + //Free'd up switches include: j, O, + // //make sure to put a colon : after each if they need an argument //or remove colon if no argument required @@ -1717,6 +1718,12 @@ main (int argc, char **argv) //NOTE: The 'K' option for single BP key has been swapped to 'b' //'K' is now used for hexidecimal key.csv imports + //this is a debug option hidden from users, but use it to replay .bin files on loop + case 'J': + state.debug_mode = 1; + fprintf (stderr, "Debug Mode Enabled; \n"); + break; + //Specify M17 encoder User Data (CAN, DST, SRC values) //NOTE: Disabled QPSK settings by borrowing these switches (nobody probalby used them anyways) case 'M': diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index 8002065..b9653ce 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -2382,6 +2382,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) printw("%s", FM_bannerN[i]); if (i == 1) printw (" ESC to Menu"); if (i == 2) printw (" 'q' to Quit "); + if (i == 3 && state->debug_mode == 1) printw (" DEBUG MODE!"); if (i == 4 && opts->frame_m17 == 0) printw (" MBElib %s", versionstr); #ifdef USE_CODEC2 if (i == 4 && opts->frame_m17 == 1) printw (" CODEC2"); diff --git a/src/dsd_symbol.c b/src/dsd_symbol.c index a23831d..0a335ce 100644 --- a/src/dsd_symbol.c +++ b/src/dsd_symbol.c @@ -658,8 +658,14 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync) // opts->audio_in_type = 0; //switch to pulse after playback, ncurses terminal can initiate replay if wanted fclose(opts->symbolfile); fprintf (stderr, "\nEnd of %s\n", opts->audio_in_dev); + //in debug mode, re-run .bin files over and over (look for memory leaks, etc) + if (state->debug_mode == 1) + { + opts->symbolfile = fopen(opts->audio_in_dev, "r"); + opts->audio_in_type = 4; //symbol capture bin files + } //open pulse input if we are pulse output AND using ncurses terminal - if (opts->audio_out_type == 0 && opts->use_ncurses_terminal == 1) + else if (opts->audio_out_type == 0 && opts->use_ncurses_terminal == 1) { opts->audio_in_type = 0; //set input type openPulseInput(opts); //open pulse input