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;
This commit is contained in:
lwvmobile
2025-05-15 16:42:21 -04:00
parent ed13bb34d8
commit 2891d7314b
10 changed files with 101 additions and 0 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -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)

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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__

View File

@@ -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)

View File

@@ -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"

View File

@@ -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);
}

View File

@@ -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)
{