From 61cefa6a87e4f1306834eddbe30c1ff7ff6cb92a Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Sat, 19 Nov 2022 19:43:48 -0500 Subject: [PATCH] Trunking Hangtime and Tweaks; NXDN F2U Tweak; --- README.md | 1 + include/dsd.h | 1 + src/dsd_frame_sync.c | 3 ++- src/dsd_main.c | 38 ++++++++++++++++++++++++++++++-------- src/nxdn_deperm.c | 26 +++++++++++++++++++++----- 5 files changed, 55 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 3af5526..bc0c5be 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ sudo make install (See group.csv for example) -3 Enable Experimental Trunking Features (P25/EDACS/NXDN-ish for now) with RIGCTL/TCP or RTL Input -5 Enable RIGCTL/TCP; Set UDP Port for RIGCTL. (4532 for SDR++) + -6 Set Trunking VC/sync loss hangtime in seconds. (default = 1 second) ``` ### Input ### diff --git a/include/dsd.h b/include/dsd.h index 4f2b9cf..937939d 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -359,6 +359,7 @@ typedef struct int p25_trunk; //experimental P25 trunking with RIGCTL (or RTLFM) int p25_is_tuned; //set to 1 if currently on VC, set back to 0 if on CC + int trunk_hangtime; //hangtime in seconds before tuning back to CC //csv import filenames char group_in_file[1024]; diff --git a/src/dsd_frame_sync.c b/src/dsd_frame_sync.c index 1abdfb8..a238af0 100644 --- a/src/dsd_frame_sync.c +++ b/src/dsd_frame_sync.c @@ -150,8 +150,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state) //start control channel hunting if using trunking, time needs updating on each successful sync //will need to assign frequencies to a CC array for P25 since that isn't imported from CSV - if (opts->p25_is_tuned == 0 && opts->p25_trunk == 1 && time(NULL) - state->last_cc_sync_time > 3) + if (opts->p25_is_tuned == 0 && opts->p25_trunk == 1 && (time(NULL) - state->last_cc_sync_time > (opts->trunk_hangtime + 2)) ) { + //test to switch back to 10/4 P1 QPSK for P25 FDMA CC if (opts->mod_qpsk == 1 && state->p25_cc_is_tdma == 0) { diff --git a/src/dsd_main.c b/src/dsd_main.c index e01be47..f1bb740 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -77,8 +77,8 @@ void noCarrier (dsd_opts * opts, dsd_state * state) { - //tune back to last knwon CC when using trunking - if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1) + //tune back to last knwon CC when using trunking after x second hangtime + if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1 && time(NULL) - state->last_cc_sync_time > opts->trunk_hangtime) { if (state->p25_cc_freq != 0) { @@ -136,11 +136,26 @@ noCarrier (dsd_opts * opts, dsd_state * state) sprintf (state->ftype, " "); state->errs = 0; state->errs2 = 0; - //should I disable this or not? - state->lasttg = 0; - state->lastsrc = 0; - state->lasttgR = 0; - state->lastsrcR = 0; + + //zero out right away if not trunking + if (opts->p25_trunk == 0) + { + state->lasttg = 0; + state->lastsrc = 0; + state->lasttgR = 0; + state->lastsrcR = 0; + } + + //zero out after x second hangtime when trunking to prevent premature zeroing on these variables + //mainly bugfix for ncurses and per call wavs (edacs) + if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1 && time(NULL) - state->last_cc_sync_time > opts->trunk_hangtime) + { + state->lasttg = 0; + state->lastsrc = 0; + state->lasttgR = 0; + state->lastsrcR = 0; + } + state->lastp25type = 0; state->repeat = 0; state->nac = 0; @@ -392,6 +407,7 @@ initOpts (dsd_opts * opts) opts->p25_trunk = 0; //0 disabled, 1 is enabled opts->p25_is_tuned = 0; //set to 1 if currently on VC, set back to 0 on carrier drop + opts->trunk_hangtime = 1; //1 second hangtime by default before tuning back to CC } @@ -647,6 +663,7 @@ initState (dsd_state * state) state->p2_cc = 0; state->p2_hardset = 0; state->p2_is_lcch = 0; + state->p25_cc_is_tdma = 2; //init on 2, TSBK NET_STS will set 0, TDMA NET_STS will set 1. //used to determine if we need to change symbol rate when cc hunting //experimental symbol file capture read throttle state->symbol_throttle = 0; //throttle speed @@ -837,6 +854,7 @@ usage () printf (" (See group.csv for example)\n"); printf (" -3 Enable Extremely Experimental Trunking Features (NXDN/P25/EDACS for now) with RIGCTL/TCP or RTL Input\n"); printf (" -5 Enable RIGCTL/TCP; Set UDP Port for RIGCTL. (4532 on SDR++)\n"); + printf (" -6 Set Trunking VC/sync loss hangtime in seconds. (default = 1 second)\n"); //printf (" (Currently only available on UDP port 4532)\n"); printf ("\n"); exit (0); @@ -1068,7 +1086,7 @@ main (int argc, char **argv) exitflag = 0; signal (SIGINT, sigfun); - while ((c = getopt (argc, argv, "haep:P:qs:tv:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:V:U:Y:K:H:X:NQWrlZTF1:2:345:")) != -1) + while ((c = getopt (argc, argv, "haep:P:qs:tv:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:V:U:Y:K:H:X:NQWrlZTF1:2:345:6:")) != -1) { opterr = 0; switch (c) @@ -1105,6 +1123,10 @@ main (int argc, char **argv) opts.use_rigctl = 1; } break; + //placeholder until letters get re-arranged + case '6': //hangtime in seconds, default is 1; + sscanf (optarg, "%d", &opts.trunk_hangtime); + break; case 'e': opts.errorbars = 1; opts.datascope = 0; diff --git a/src/nxdn_deperm.c b/src/nxdn_deperm.c index b956f42..0301441 100644 --- a/src/nxdn_deperm.c +++ b/src/nxdn_deperm.c @@ -384,8 +384,22 @@ void nxdn_deperm_facch2_udch(dsd_opts * opts, dsd_state * state, uint8_t bits[34 crc = crc15(trellis_buf, 199); - fprintf (stderr, " F2/U "); - if (crc == 0) NXDN_Elements_Content_decode(opts, state, 1, trellis_buf); + uint8_t f2u_message_buffer[199]; + memset (f2u_message_buffer, 0, sizeof(f2u_message_buffer)); + + //just going to leave this all here in case its needed, like in cac, + //don't have any samples with f2 or udch data in it + for (int i = 0; i < 199-8; i++) + { + f2u_message_buffer[i] = trellis_buf[i+8]; + } + + if (crc == 0) + { + fprintf (stderr, " F2/U "); + //NXDN_Elements_Content_decode(opts, state, 1, trellis_buf); + NXDN_Elements_Content_decode(opts, state, 1, f2u_message_buffer); + } if (opts->payload == 1) { @@ -476,8 +490,6 @@ void nxdn_deperm_cac(dsd_opts * opts, dsd_state * state, uint8_t bits[300]) crc = crc16cac(trellis_buf, 171); - fprintf (stderr, " CAC "); - //message type will probably be neccesary beforehand on single/dual meessage runs //run message, check len, load into a seperate buffer, send to element, do same with other piece? uint8_t MessageType = 0; @@ -496,7 +508,11 @@ void nxdn_deperm_cac(dsd_opts * opts, dsd_state * state, uint8_t bits[300]) cac_message_buffer[i] = trellis_buf[i+8]; } - if (crc == 0) NXDN_Elements_Content_decode(opts, state, 1, cac_message_buffer); + if (crc == 0) + { + fprintf (stderr, " CAC "); + NXDN_Elements_Content_decode(opts, state, 1, cac_message_buffer); + } if (opts->payload == 1) {