From 2891d7314b4d053b4c20e13502d40df86db38380 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Thu, 15 May 2025 16:42:21 -0400 Subject: [PATCH] Dibit/Symbol Capture File: When initiated from the ncurses 'R' key, it now rotates every hour; Above is logged to event history when it occurs; --- include/dsd.h | 3 +++ src/dmr_csbk.c | 12 ++++++++++++ src/dmr_flco.c | 4 ++++ src/dsd_file.c | 39 +++++++++++++++++++++++++++++++++++++++ src/dsd_main.c | 6 ++++++ src/dsd_ncurses_handler.c | 23 +++++++++++++++++++++++ src/edacs-fme.c | 3 +++ src/nxdn_deperm.c | 3 +++ src/p25p1_tsbk.c | 4 ++++ src/p25p2_frame.c | 4 ++++ 10 files changed, 101 insertions(+) diff --git a/include/dsd.h b/include/dsd.h index 281b998..98f3915 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -311,6 +311,8 @@ typedef struct FILE *mbe_out_f; FILE *mbe_out_fR; //second slot on a TDMA system FILE *symbol_out_f; + time_t symbol_out_file_creation_time; //time the symbol out file was created + uint8_t symbol_out_file_is_auto; //if the user hit the R key float audio_gain; float audio_gainR; float audio_gainA; @@ -1166,6 +1168,7 @@ SNDFILE * close_and_rename_wav_file(SNDFILE * wav_file, char * wav_out_filename, SNDFILE * close_and_delete_wav_file(SNDFILE * wav_file, char * wav_out_filename); void openSymbolOutFile (dsd_opts * opts, dsd_state * state); void closeSymbolOutFile (dsd_opts * opts, dsd_state * state); +void rotate_symbol_out_file (dsd_opts * opts, dsd_state * state); void writeRawSample (dsd_opts * opts, dsd_state * state, short sample); void closeWavOutFile (dsd_opts * opts, dsd_state * state); void closeWavOutFileL (dsd_opts * opts, dsd_state * state); diff --git a/src/dmr_csbk.c b/src/dmr_csbk.c index 8c12232..ae0455e 100644 --- a/src/dmr_csbk.c +++ b/src/dmr_csbk.c @@ -430,6 +430,10 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 if (ccfreq != 0) state->p25_cc_freq = ccfreq; } + //when on a CC, rotate the symbol out file every hour, if enabled + if (opts->p25_is_tuned == 0) //if not currently tuned on Tier 3 system + rotate_symbol_out_file(opts, state); //may need a second check to make sure other slot on T3 standard isn't busy as well + } //P_CLEAR @@ -1579,6 +1583,10 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //Test allowing a tg hold to pre-empt a call in progress and tune to the hold TG if (state->tg_hold != 0) state->last_vc_sync_time = 0; + //if no activity in this window + if ( (time(NULL) - state->last_vc_sync_time) > 2 ) //may use last_cc_sync_time instead + rotate_symbol_out_file(opts, state); + //TODO: Consider a method to allow moving the frequency to the rest channel //when a TG hold is specified but nether slot carries the TG on Hold; //CODED: using slow link control for that @@ -2163,6 +2171,10 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //Test allowing a tg hold to pre-empt a call in progress and tune to the hold TG if (state->tg_hold != 0) state->last_vc_sync_time = 0; + //if no activity in this window + if ( (time(NULL) - state->last_vc_sync_time) > 2 ) //may use last_cc_sync_time instead + rotate_symbol_out_file(opts, state); + //TODO: Consider a method to allow moving the frequency to the free repeater channel //when a TG hold is specified but nether slot carries the TG on Hold; //CODED: using Free repeater in SLC to change over if required diff --git a/src/dmr_flco.c b/src/dmr_flco.c index 529405d..c8a1675 100644 --- a/src/dmr_flco.c +++ b/src/dmr_flco.c @@ -1155,6 +1155,10 @@ void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[]) if (ccfreq != 0) state->p25_cc_freq = ccfreq; } + //if on Con+ control channel and no activity in this window + if ( (time(NULL) - state->last_vc_sync_time) > 2 ) //may use last_cc_sync_time instead + rotate_symbol_out_file(opts, state); + } else if (slco == 0xF) diff --git a/src/dsd_file.c b/src/dsd_file.c index 257d66e..a5cf230 100644 --- a/src/dsd_file.c +++ b/src/dsd_file.c @@ -684,6 +684,45 @@ void closeSymbolOutFile (dsd_opts * opts, dsd_state * state) } } +void rotate_symbol_out_file (dsd_opts * opts, dsd_state * state) +{ + if (opts->symbol_out_f && opts->symbol_out_file_is_auto == 1) + { + if ( (time(NULL) - opts->symbol_out_file_creation_time) >= 3600 ) //3600 is one hour in seconds + { + //basically just lift the close and open from ncurses handler for 'r' and then 'R' + // closeSymbolOutFile (opts, state); //open also does this, so don't need to do it twice + char * timestr = getTime(); + char * datestr = getDate(); + sprintf (opts->symbol_out_file, "%s_%s_dibit_capture.bin", datestr, timestr); + openSymbolOutFile (opts, state); + + //add a system event to echo in the event history + state->event_history_s[0].Event_History_Items[0].color_pair = 4; + char event_str[200]; memset (event_str, 0, sizeof(event_str)); + sprintf (event_str, "DSD-FME Dibit Capture File Rotated: %s;", opts->symbol_out_file); + watchdog_event_datacall (opts, state, 0xFFFFFF, 0xFFFFFF, event_str, 0); + state->lastsrc = 0; //this could wipe a call, but usually on TDMA cc's, slot 1 is the control channel, so may never be set when this is run + watchdog_event_history(opts, state, 0); + watchdog_event_current(opts, state, 0); + + //allocated memory pointer needs to be free'd + if (timestr != NULL) + { + free (timestr); + timestr = NULL; + } + if (datestr != NULL) + { + free (datestr); + datestr = NULL; + } + opts->symbol_out_file_creation_time = time(NULL); + // opts->symbol_out_file_is_auto = 1; + } + } +} + //input bit array, return output as up to a 64-bit value uint64_t convert_bits_into_output(uint8_t * input, int len) { diff --git a/src/dsd_main.c b/src/dsd_main.c index d0ff152..9aff878 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -106,6 +106,10 @@ void noCarrier (dsd_opts * opts, dsd_state * state) { + + + //when no carrier sync, rotate the symbol out file every hour, if enabled + rotate_symbol_out_file(opts, state); //this should handle any conventional system where no sync conditions occur when no activity if (opts->floating_point == 1) { @@ -636,6 +640,8 @@ //end import filenames opts->szNumbers[0] = 0; opts->symbol_out_f = NULL; + opts->symbol_out_file_creation_time = time(NULL); + opts->symbol_out_file_is_auto = 0; opts->mbe_out = 0; opts->mbe_outR = 0; //second slot on a TDMA system opts->wav_out_f = NULL; diff --git a/src/dsd_ncurses_handler.c b/src/dsd_ncurses_handler.c index be998dc..9b1b0c1 100644 --- a/src/dsd_ncurses_handler.c +++ b/src/dsd_ncurses_handler.c @@ -296,6 +296,16 @@ uint8_t ncurses_input_handler(dsd_opts * opts, dsd_state * state, int c) char * datestr = getDate(); sprintf (opts->symbol_out_file, "%s_%s_dibit_capture.bin", datestr, timestr); openSymbolOutFile (opts, state); + + //add a system event to echo in the event history + state->event_history_s[0].Event_History_Items[0].color_pair = 4; + char event_str[200]; memset (event_str, 0, sizeof(event_str)); + sprintf (event_str, "DSD-FME Dibit Capture File Started: %s;", opts->symbol_out_file); + watchdog_event_datacall (opts, state, 0xFFFFFF, 0xFFFFFF, event_str, 0); + state->lastsrc = 0; //this could wipe a call src if they hit 'R' while call in slot 1 in progress + watchdog_event_history(opts, state, 0); + watchdog_event_current(opts, state, 0); + //allocated memory pointer needs to be free'd if (timestr != NULL) { @@ -307,6 +317,8 @@ uint8_t ncurses_input_handler(dsd_opts * opts, dsd_state * state, int c) free (datestr); datestr = NULL; } + opts->symbol_out_file_creation_time = time(NULL); + opts->symbol_out_file_is_auto = 1; } if (c == 114) //'r' key, stop capturing symbol capture bin file @@ -315,7 +327,18 @@ uint8_t ncurses_input_handler(dsd_opts * opts, dsd_state * state, int c) { closeSymbolOutFile (opts, state); sprintf (opts->audio_in_dev, "%s", opts->symbol_out_file); + + //add a system event to echo in the event history + state->event_history_s[0].Event_History_Items[0].color_pair = 4; + char event_str[200]; memset (event_str, 0, sizeof(event_str)); + sprintf (event_str, "DSD-FME Dibit Capture File Closed: %s;", opts->symbol_out_file); + watchdog_event_datacall (opts, state, 0xFFFFFF, 0xFFFFFF, event_str, 0); + state->lastsrc = 0; //this could wipe a call src if they hit 'R' while call in slot 1 in progress + watchdog_event_history(opts, state, 0); + watchdog_event_current(opts, state, 0); + } + opts->symbol_out_file_is_auto = 0; } #ifdef __CYGWIN__ diff --git a/src/edacs-fme.c b/src/edacs-fme.c index 708628b..73cd8c2 100644 --- a/src/edacs-fme.c +++ b/src/edacs-fme.c @@ -2263,6 +2263,9 @@ void edacs(dsd_opts * opts, dsd_state * state) fprintf (stderr, "\n"); + //when on a CC, rotate the symbol out file every hour, if enabled + rotate_symbol_out_file(opts, state); + } void eot_cc(dsd_opts * opts, dsd_state * state) diff --git a/src/nxdn_deperm.c b/src/nxdn_deperm.c index 06622dd..31b2cfa 100644 --- a/src/nxdn_deperm.c +++ b/src/nxdn_deperm.c @@ -782,6 +782,9 @@ void nxdn_deperm_cac(dsd_opts * opts, dsd_state * state, uint8_t bits[300]) } + //when on a CC, rotate the symbol out file every hour, if enabled + rotate_symbol_out_file(opts, state); + } //Type-D "IDAS" diff --git a/src/p25p1_tsbk.c b/src/p25p1_tsbk.c index 873793c..3682265 100644 --- a/src/p25p1_tsbk.c +++ b/src/p25p1_tsbk.c @@ -667,4 +667,8 @@ void processTSBK(dsd_opts * opts, dsd_state * state) fprintf (stderr, "%s ", KNRM); fprintf (stderr, "\n"); + + //when on a CC, rotate the symbol out file every hour, if enabled + rotate_symbol_out_file(opts, state); + } diff --git a/src/p25p2_frame.c b/src/p25p2_frame.c index f16a912..408b3e4 100644 --- a/src/p25p2_frame.c +++ b/src/p25p2_frame.c @@ -970,6 +970,10 @@ void process_P2_DUID (dsd_opts * opts, dsd_state * state) { // sacch = 1; //only an 'inverted' slot when its TS index 10 or 11 fprintf (stderr, "LCCH "); + + //when on a CC, rotate the symbol out file every hour, if enabled + if (opts->p25_is_tuned == 0) + rotate_symbol_out_file(opts, state); } else if (duid_decoded == 4) //Scrambled LCCH (TDMA_CC only...look in the manual again) {