diff --git a/examples/cygwin_bat/start-dsd-fme.bat b/examples/cygwin_bat/start-dsd-fme.bat index 7333416..ec255f8 100644 --- a/examples/cygwin_bat/start-dsd-fme.bat +++ b/examples/cygwin_bat/start-dsd-fme.bat @@ -59,8 +59,8 @@ set "elog=.\logs\event_log_%datetimestr%_%rnd%.txt" start .\dsd-fme\tail.exe -n 40 -f %clog% start .\dsd-fme\tail.exe -n 40 -f %elog% -@REM start dsd-fme with options and log -.\dsd-fme\dsd-fme.exe %options% -~ %elog% 2> %clog% +@REM start dsd-fme with options and logs +.\dsd-fme\dsd-fme.exe %options% -J %elog% 2> %clog% echo ---------------------------------------------------------------------------------- echo ---------------------------------------------------------------------------------- diff --git a/include/dsd.h b/include/dsd.h index 4358529..2c2bfa8 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -1412,7 +1412,7 @@ char * getDateN(time_t t); //event history functions void init_event_history (Event_History_I * event_struct, uint8_t start, uint8_t stop); void push_event_history (Event_History_I * event_struct); -void write_event_to_log_file (dsd_opts * opts, dsd_state * state, char * event_string); +void write_event_to_log_file (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t swrite, char * event_string); void watchdog_event_history (dsd_opts * opts, dsd_state * state, uint8_t slot); void watchdog_event_current (dsd_opts * opts, dsd_state * state, uint8_t slot); void watchdog_event_datacall (dsd_opts * opts, dsd_state * state, uint32_t src, uint32_t dst, char * data_string, uint8_t slot); diff --git a/src/dsd_frame.c b/src/dsd_frame.c index 1b8daf2..8391062 100644 --- a/src/dsd_frame.c +++ b/src/dsd_frame.c @@ -37,10 +37,10 @@ printFrameInfo (dsd_opts * opts, dsd_state * state) fprintf (stderr, "NAC/CC: %03llX; ", state->p2_cc); else fprintf (stderr, "NAC: %03X; ", state->nac); - if (state->p2_siteid != 0) - fprintf (stderr, "Site: %03lld; ", state->p2_siteid); if (state->p2_rfssid != 0) fprintf (stderr, "RFSS: %03lld; ", state->p2_rfssid); + if (state->p2_siteid != 0) + fprintf (stderr, "Site: %03lld; ", state->p2_siteid); fprintf (stderr, "%s", KNRM); } diff --git a/src/dsd_main.c b/src/dsd_main.c index 1e8502b..a4054ad 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -1412,7 +1412,7 @@ printf (" (Running in console will use static wav files)\n"); printf (" -a Enable Call Alert Beep (NCurses Terminal Only)\n"); printf (" (Warning! Might be annoying.)\n"); - printf (" -~ Specify Filename for Event Log Output.\n"); + printf (" -J Specify Filename for Event Log Output.\n"); printf (" -L Specify Filename for LRRP Data Output.\n"); printf (" -Q Specify Filename for OK-DMRlib Structured File Output. (placed in DSP folder)\n"); printf (" -Q Specify Filename for M17 Float Stream Output. (placed in DSP folder)\n"); @@ -1644,10 +1644,10 @@ char event_string[2000]; memset (event_string, 0, sizeof(event_string)); sprintf (event_string, "%s %s DSD-FME Started and Event History Initialized;", datestr, timestr); - write_event_to_log_file (opts, state, event_string); + write_event_to_log_file (opts, state, 0, 0, event_string); memset (event_string, 0, sizeof(event_string)); sprintf (event_string, "%s %s Any decoded voice calls or data calls display here;", datestr, timestr); - write_event_to_log_file (opts, state, event_string); + write_event_to_log_file (opts, state, 0, 0, event_string); if (timestr != NULL) { @@ -1830,7 +1830,7 @@ 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:JO")) != -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:O")) != -1) { switch (c) @@ -1854,7 +1854,7 @@ //'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': + case '~': state.debug_mode = 1; fprintf (stderr, "Debug Mode Enabled; \n"); break; @@ -2193,7 +2193,7 @@ fprintf (stderr,"Writing + Appending LRRP data to file %s\n", opts.lrrp_out_file); break; - case '~': //Event output to file + case 'J': //Event output to file (J for Journal) strncpy(opts.event_out_file, optarg, 1023); opts.event_out_file[1023] = '\0'; fprintf (stderr,"Writing + Appending Event History to file %s\n", opts.lrrp_out_file); diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index 688751b..31057a8 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -4463,16 +4463,19 @@ void push_event_history (Event_History_I * event_struct) } } -void write_event_to_log_file (dsd_opts * opts, dsd_state * state, char * event_string) //pass completed event string here that is in the struct +void write_event_to_log_file (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t swrite, char * event_string) //pass completed event string here that is in the struct { //open log file FILE * event_log_file; event_log_file = fopen(opts->event_out_file, "a"); - fprintf (event_log_file, "%s \n", event_string); + fprintf (event_log_file, "%s ", event_string); + if (swrite == 1) + fprintf (event_log_file, "Slot %d; ", slot+1); + fprintf (event_log_file,"\n"); + char text_string[2000]; sprintf (text_string, "%s", "BUMBLEBEETUNA"); - uint8_t slot = state->currentslot; if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[0].text_message, 13) != 0) fprintf (event_log_file, "%s \n", state->event_history_s[slot].Event_History_Items[0].text_message); if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[0].alias, 13) != 0) @@ -4492,6 +4495,9 @@ void watchdog_event_history (dsd_opts * opts, dsd_state * state, uint8_t slot) //create a pointer to the current slot event history Event_History_I * event_struct = &state->event_history_s[slot]; + //is this a TDMA slot (append Slot value to end of written event history) + uint8_t swrite = 0; + //who is currently talking uint32_t source_id = 0; @@ -4503,6 +4509,13 @@ void watchdog_event_history (dsd_opts * opts, dsd_state * state, uint8_t slot) else source_id = state->lastsrcR; + //if DMR BS or P25P2, then flag the swrite, so write can append slot value to event history log //|| state->lastsynctype == 32 || state->lastsynctype == 33 || state->lastsynctype == 34 MS + if (state->lastsynctype == 10 || state->lastsynctype == 11 || state->lastsynctype == 12 || state->lastsynctype == 13) + swrite = 1; + + else if (state->lastsynctype == 35 || state->lastsynctype == 36) + swrite = 1; + if (slot == 0) //BUGFIX: generic catch on FDMA systems so that we don't write duplicate data to slot 2 event history { //NXDN RID (TODO: Changeover to lastsrc later on) @@ -4560,7 +4573,9 @@ void watchdog_event_history (dsd_opts * opts, dsd_state * state, uint8_t slot) { if (opts->event_out_file[0] != 0) - write_event_to_log_file(opts, state, event_struct->Event_History_Items[0].event_string); + write_event_to_log_file(opts, state, slot, swrite, event_struct->Event_History_Items[0].event_string); + + event_struct->Event_History_Items[0].write = 1; //written, or pushed at this point if (slot == 0 && opts->wav_out_f != NULL) { @@ -4923,7 +4938,7 @@ void watchdog_event_current (dsd_opts * opts, dsd_state * state, uint8_t slot) if (source_id != 0) { - event_struct->Event_History_Items[0].write = 1; //TODO: Write a 1 here after written to a log + event_struct->Event_History_Items[0].write = 0; if (state->lastsynctype != -1) event_struct->Event_History_Items[0].systype = state->lastsynctype; else event_struct->Event_History_Items[0].systype = 39; //generic digital call @@ -5118,7 +5133,7 @@ void watchdog_event_current (dsd_opts * opts, dsd_state * state, uint8_t slot) void watchdog_event_datacall (dsd_opts * opts, dsd_state * state, uint32_t src, uint32_t dst, char * data_string, uint8_t slot) { UNUSED(opts); - state->event_history_s[slot].Event_History_Items[0].write = 1; //TODO: Write a 1 here when written to a log + state->event_history_s[slot].Event_History_Items[0].write = 0; state->event_history_s[slot].Event_History_Items[0].systype = state->lastsynctype; state->event_history_s[slot].Event_History_Items[0].subtype = 6; //data state->event_history_s[slot].Event_History_Items[0].gi = state->gi[slot];