More NCURSES Tweaking
More NCURSES Tweaking -tweak array, seems to update smoother now, immediate -more concise, cleaner names for sync types -array updates on DMR, P25P1, NXDN, PV types only currenlty (no dstar etc yet) More P25 resetState tweaking/testing Other under the hood tweaking
This commit is contained in:
parent
af401a7e5b
commit
387f2253b1
|
|
@ -14,7 +14,7 @@ find_package(RTLSDR)
|
|||
#more messing around
|
||||
#find_package(Curses)
|
||||
find_package(Curses REQUIRED) #making this required until I can fix all instances of it being called to ifdef lines
|
||||
find_package(PULSEAUDIO)
|
||||
find_package(PulseAudio)
|
||||
|
||||
#include_directories(SYSTEM ${LIBSNDFILE_INCLUDE_DIR} ${MBE_INCLUDE_DIR} ${ITPP_INCLUDE_DIR} ${PULSEAUDIO_INCLUDE_DIRS} ${CURSES_INCLUDE_DIR})
|
||||
#set(LIBS ${MBE_LIBRARY} ${LIBSNDFILE_LIBRARY} ${ITPP_LIBRARY} ${PULSEAUDIO_SIMPLE_LIBRARY} ${CURSES_LIBRARY})
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
|
||||
#include "dsd.h"
|
||||
|
||||
int payload = 0;
|
||||
void
|
||||
saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d)
|
||||
{
|
||||
|
|
@ -28,17 +28,28 @@ saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d)
|
|||
fputc (err, opts->mbe_out_f);
|
||||
|
||||
k = 0;
|
||||
if (payload == 1) //make opt variable later on to toggle this
|
||||
{
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
for (i = 0; i < 11; i++)
|
||||
{
|
||||
b = 0;
|
||||
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
b = b << 1;
|
||||
b = b + imbe_d[k];
|
||||
k++;
|
||||
}
|
||||
if (payload == 1) //make opt variable later on to toggle this
|
||||
{
|
||||
fprintf (stderr, "[%2X] ", b);
|
||||
}
|
||||
fputc (b, opts->mbe_out_f);
|
||||
}
|
||||
//fprintf(stderr, "\n");
|
||||
fflush (opts->mbe_out_f);
|
||||
}
|
||||
|
||||
|
|
@ -53,17 +64,28 @@ saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
|
|||
fputc (err, opts->mbe_out_f);
|
||||
|
||||
k = 0;
|
||||
if (payload == 1) //make opt variable later on to toggle this
|
||||
{
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
b = 0;
|
||||
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
b = b << 1;
|
||||
b = b + ambe_d[k];
|
||||
k++;
|
||||
}
|
||||
if (payload == 1) //make opt variable later on to toggle this
|
||||
{
|
||||
fprintf (stderr, "[%2X] ", b);
|
||||
}
|
||||
|
||||
fputc (b, opts->mbe_out_f);
|
||||
}
|
||||
//fprintf(stderr, "\n");
|
||||
b = ambe_d[48];
|
||||
fputc (b, opts->mbe_out_f);
|
||||
fflush (opts->mbe_out_f);
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ usage ()
|
|||
fprintf (stderr," -d <dir> Create mbe data files, use this directory\n");
|
||||
fprintf (stderr," -r <files> Read/Play saved mbe data from file(s)\n");
|
||||
fprintf (stderr," -g <num> Audio output gain (default = 0 = auto, disable = -1)\n");
|
||||
fprintf (stderr," -n Do not send synthesized speech to audio output device\n");
|
||||
//fprintf (stderr," -n Do not send synthesized speech to audio output device\n");
|
||||
fprintf (stderr," -w <file> Output synthesized speech to a .wav file\n");
|
||||
fprintf (stderr," -a Display port audio devices\n");
|
||||
fprintf (stderr," -W Monitor Source Audio When No Sync Detected (WIP!)\n");
|
||||
|
|
@ -381,6 +381,9 @@ usage ()
|
|||
fprintf (stderr," (default=36)\n");
|
||||
fprintf (stderr," -M <num> Min/Max buffer size for QPSK decision point tracking\n");
|
||||
fprintf (stderr," (default=15)\n");
|
||||
fprintf (stderr," -n Reset P25 Heuristics and initState variables on mixed decoding signal\n");
|
||||
fprintf (stderr," Helps when decoding multiple signal types at same time\n");
|
||||
fprintf (stderr," (WiP! May Cause Slow Memory Leak - Experimental)\n");
|
||||
fprintf (stderr,"\n");
|
||||
fprintf (stderr,"Report bugs to: https://github.com/lwvmobile/dsd-fme/issues \n");
|
||||
exit (0);
|
||||
|
|
@ -715,6 +718,7 @@ main (int argc, char **argv)
|
|||
case 'N':
|
||||
opts.use_ncurses_terminal = 1;
|
||||
fprintf (stderr,"Enabling NCurses Terminal.\n");
|
||||
fprintf (stderr," - may need to issue 'reset' command in terminal after use\n");
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
|
|
@ -767,6 +771,9 @@ main (int argc, char **argv)
|
|||
//opts.audio_out = 0;
|
||||
//fprintf (stderr,"Disabling audio output to soundcard.\n");
|
||||
opts.reset_state = 1;
|
||||
fprintf (stderr,"Enabling Automatic Reset of P25 states\n");
|
||||
fprintf (stderr," -Helps with multiple signal type decoding\n");
|
||||
fprintf (stderr," -(WiP! May cause slow memory leak)\n");
|
||||
break;
|
||||
case 'w':
|
||||
strncpy(opts.wav_out_file, optarg, 1023);
|
||||
|
|
@ -1090,6 +1097,7 @@ main (int argc, char **argv)
|
|||
else
|
||||
{
|
||||
liveScanner (&opts, &state);
|
||||
|
||||
}
|
||||
if (opts.use_ncurses_terminal == 1){
|
||||
ncursesClose ();
|
||||
|
|
|
|||
|
|
@ -27,16 +27,7 @@
|
|||
|
||||
#include "dsd.h"
|
||||
#include "git_ver.h"
|
||||
/*
|
||||
short hexbuf;
|
||||
unsigned long long sr_0 = 0; //64-bit shift registers for pushing decoded binary or dibit data
|
||||
unsigned long long sr_1 = 0; //384
|
||||
unsigned long long sr_2 = 0; //
|
||||
unsigned long long sr_3 = 0; //
|
||||
unsigned long long sr_4 = 0; //
|
||||
unsigned long long sr_5 = 0; //
|
||||
unsigned long long sr_6 = 0; //
|
||||
*/
|
||||
|
||||
int reset = 0;
|
||||
char c; //getch key
|
||||
int tg; //last tg
|
||||
|
|
@ -62,6 +53,7 @@ char * FM_bannerN[9] = {
|
|||
"https://github.com/lwvmobile/dsd-fme/tree/pulseaudio "
|
||||
};
|
||||
|
||||
/*
|
||||
char * SyncTypes[20] = {
|
||||
"P25P1_SYNC",
|
||||
"INV_P25P1_SYNC",
|
||||
|
|
@ -84,6 +76,30 @@ char * SyncTypes[20] = {
|
|||
"DSTAR_HD",
|
||||
"INV_DSTAR_HD"
|
||||
|
||||
};
|
||||
*/
|
||||
char * SyncTypes[20] = {
|
||||
"+P25P1",
|
||||
"-P25P1",
|
||||
"+X2TDMA DATA",
|
||||
"-X2TDMA DATA",
|
||||
"+X2TDMA VOICE",
|
||||
"-X2TDMA VOICE",
|
||||
"+DSTARC",
|
||||
"-DSTAR",
|
||||
"+NXDN VOICE", //8
|
||||
"-NXDN VOICE", //9
|
||||
"+DMR DATA", //10
|
||||
"-DMR VOICE", //11
|
||||
"+DMR DATA", //12
|
||||
"-DMR VOICE", //13
|
||||
"+PROVOICE", //14
|
||||
"-PROVOICE", //15
|
||||
"+NXDN DATA", //16
|
||||
"-NXDN DATA", //17
|
||||
"+DSTAR HD",
|
||||
"-DSTAR HD"
|
||||
|
||||
};
|
||||
|
||||
time_t nowN;
|
||||
|
|
@ -115,7 +131,7 @@ void ncursesOpen ()
|
|||
init_pair(5, COLOR_MAGENTA, COLOR_BLACK); //Magenta for no frame sync/signal
|
||||
noecho();
|
||||
cbreak();
|
||||
fprintf (stderr, "Opening NCurses Terminal. \n");
|
||||
//fprintf (stderr, "Opening NCurses Terminal. \n");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -143,39 +159,9 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||
printw ("------------------------------------------------------------------------------\n");
|
||||
|
||||
|
||||
if ( (state->lastsynctype == 14 || state->lastsynctype == 15) ) //honestly have no idea how to do this for pV
|
||||
if ( (lls == 14 || lls == 15) && (time(NULL) - call_matrix[9][5] > 5) ) //honestly have no idea how to do this for pV, just going time based?
|
||||
{
|
||||
call_matrix[5][0] = lls;
|
||||
call_matrix[5][1] = 1;
|
||||
call_matrix[5][2] = 1;
|
||||
call_matrix[5][3] = 1;
|
||||
call_matrix[5][4] = 1;
|
||||
call_matrix[5][5] = time(NULL);
|
||||
}
|
||||
|
||||
if ( (state->nxdn_last_rid != src && src > 0) || (state->nxdn_last_ran != rn && rn > 0) ) //find condition to make this work well, probably if last != local last variables
|
||||
{
|
||||
for (short int k = 0; k < 5; k++)
|
||||
{
|
||||
call_matrix[k][0] = call_matrix[k+1][0];
|
||||
call_matrix[k][1] = call_matrix[k+1][1];
|
||||
call_matrix[k][2] = call_matrix[k+1][2];
|
||||
call_matrix[k][3] = call_matrix[k+1][3];
|
||||
call_matrix[k][4] = call_matrix[k+1][4];
|
||||
call_matrix[k][5] = call_matrix[k+1][5];
|
||||
}
|
||||
call_matrix[5][0] = lls;
|
||||
call_matrix[5][1] = rn;
|
||||
call_matrix[5][2] = src;
|
||||
call_matrix[5][3] = 0;
|
||||
call_matrix[5][4] = 0;
|
||||
call_matrix[5][5] = time(NULL);
|
||||
|
||||
}
|
||||
|
||||
if ( (lls == 0 || lls == 1) && state->lastsrc != rd && state->lastsrc > 0) //find condition to make this work well, probably if last != local last variables
|
||||
{
|
||||
for (short int k = 0; k < 5; k++)
|
||||
for (short int k = 0; k < 9; k++)
|
||||
{
|
||||
call_matrix[k][0] = call_matrix[k+1][0];
|
||||
call_matrix[k][1] = call_matrix[k+1][1];
|
||||
|
|
@ -185,12 +171,79 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||
call_matrix[k][5] = call_matrix[k+1][5];
|
||||
}
|
||||
|
||||
call_matrix[5][0] = lls;
|
||||
call_matrix[5][1] = tg;
|
||||
call_matrix[5][2] = rd;
|
||||
call_matrix[5][3] = 0;
|
||||
call_matrix[5][4] = nc;
|
||||
call_matrix[5][5] = time(NULL);
|
||||
call_matrix[9][0] = lls;
|
||||
call_matrix[9][1] = 1;
|
||||
call_matrix[9][2] = 1;
|
||||
call_matrix[9][3] = 1;
|
||||
call_matrix[9][4] = 1;
|
||||
call_matrix[9][5] = time(NULL);
|
||||
//nowN = time(NULL);
|
||||
}
|
||||
|
||||
//if ( (state->nxdn_last_rid != src && src > 0) || (state->nxdn_last_ran != rn && rn > 0) ) //find condition to make this work well, probably if last != local last variables
|
||||
//if ( (call_matrix[9][2] != src && src > 0) || (call_matrix[9][1] != rn && rn > 0) ) //NXDN working well now with this, updates immediately and only once
|
||||
if ( call_matrix[9][2] != src && src > 0 && rn > 0 ) //NXDN working well now with this, updates immediately and only once
|
||||
{
|
||||
for (short int k = 0; k < 9; k++)
|
||||
{
|
||||
call_matrix[k][0] = call_matrix[k+1][0];
|
||||
call_matrix[k][1] = call_matrix[k+1][1];
|
||||
call_matrix[k][2] = call_matrix[k+1][2];
|
||||
call_matrix[k][3] = call_matrix[k+1][3];
|
||||
call_matrix[k][4] = call_matrix[k+1][4];
|
||||
call_matrix[k][5] = call_matrix[k+1][5];
|
||||
}
|
||||
call_matrix[9][0] = lls;
|
||||
call_matrix[9][1] = rn;
|
||||
call_matrix[9][2] = src;
|
||||
call_matrix[9][3] = 0;
|
||||
call_matrix[9][4] = 0;
|
||||
call_matrix[9][5] = time(NULL);
|
||||
|
||||
}
|
||||
|
||||
//if (state->dmr_color_code != dcc && (lls == 11 || lls == 13 || lls == 10 || lls == 12) ) //DMR Voice + last two is data
|
||||
if ( (call_matrix[9][4] != dcc || call_matrix[9][2] != rd) && (lls == 11 || lls == 13 || lls == 10 || lls == 12) ) //DMR Voice + last two is data
|
||||
{
|
||||
//dcc = state->dmr_color_code;
|
||||
for (short int k = 0; k < 9; k++)
|
||||
{
|
||||
call_matrix[k][0] = call_matrix[k+1][0];
|
||||
call_matrix[k][1] = call_matrix[k+1][1];
|
||||
call_matrix[k][2] = call_matrix[k+1][2];
|
||||
call_matrix[k][3] = call_matrix[k+1][3];
|
||||
call_matrix[k][4] = call_matrix[k+1][4];
|
||||
call_matrix[k][5] = call_matrix[k+1][5];
|
||||
}
|
||||
|
||||
call_matrix[9][0] = lls;
|
||||
call_matrix[9][1] = tg;
|
||||
call_matrix[9][2] = rd;
|
||||
call_matrix[9][3] = 0;
|
||||
call_matrix[9][4] = dcc;
|
||||
call_matrix[9][5] = time(NULL);
|
||||
//i++;
|
||||
}
|
||||
|
||||
//if ( (lls == 0 || lls == 1) && state->lastsrc != rd && state->lastsrc > 0) //find condition to make this work well, probably if last != local last variables
|
||||
if ( (lls == 0 || lls == 1) && call_matrix[9][2] != rd && nc > 0 && tg > 0) //P25
|
||||
{
|
||||
for (short int k = 0; k < 9; k++)
|
||||
{
|
||||
call_matrix[k][0] = call_matrix[k+1][0];
|
||||
call_matrix[k][1] = call_matrix[k+1][1];
|
||||
call_matrix[k][2] = call_matrix[k+1][2];
|
||||
call_matrix[k][3] = call_matrix[k+1][3];
|
||||
call_matrix[k][4] = call_matrix[k+1][4];
|
||||
call_matrix[k][5] = call_matrix[k+1][5];
|
||||
}
|
||||
|
||||
call_matrix[9][0] = lls;
|
||||
call_matrix[9][1] = tg;
|
||||
call_matrix[9][2] = rd;
|
||||
call_matrix[9][3] = 0;
|
||||
call_matrix[9][4] = nc;
|
||||
call_matrix[9][5] = time(NULL);
|
||||
//i++;
|
||||
}
|
||||
//printw ("Time: ");
|
||||
|
|
@ -199,7 +252,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||
printw ("--Input Output----------------------------------------------------------------\n");
|
||||
if (opts->audio_in_type == 0)
|
||||
{
|
||||
printw ("| Pulse Audio Input [%i] kHz [%i] Channel\n", opts->pulse_digi_rate_in, opts->pulse_digi_in_channels);
|
||||
printw ("| Pulse Audio Input [%i] kHz [%i] Channel\n", opts->pulse_digi_rate_in/1000, opts->pulse_digi_in_channels);
|
||||
}
|
||||
if (opts->audio_in_type == 1)
|
||||
{
|
||||
|
|
@ -216,7 +269,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||
}
|
||||
if (opts->audio_out_type == 0)
|
||||
{
|
||||
printw ("| Pulse Audio Output [%i] kHz [%i] Channel\n", opts->pulse_digi_rate_out, opts->pulse_digi_out_channels);
|
||||
printw ("| Pulse Audio Output [%i] kHz [%i] Channel\n", opts->pulse_digi_rate_out/1000, opts->pulse_digi_out_channels);
|
||||
}
|
||||
if (opts->mbe_out_dir[0] != 0)
|
||||
{
|
||||
|
|
@ -311,7 +364,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||
printw ("%s \n", s1last);
|
||||
}
|
||||
|
||||
if (state->dmr_color_code > 0 && (lls == 11 || lls == 13) ) //DMR VOice
|
||||
if (state->dmr_color_code > 0 && (lls == 11 || lls == 13 || lls == 10 || lls == 12) ) //DMR Voice + last two is data
|
||||
{
|
||||
dcc = state->dmr_color_code;
|
||||
}
|
||||
|
|
@ -361,36 +414,36 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||
//0 - sync type; 1 - tg/ran; 2 - rid; 3 - slot; 4 - cc; 5 - time(NULL) ;
|
||||
|
||||
printw ("--Call History----------------------------------------------------------------\n");
|
||||
for (short int j = 0; j < 6; j++)
|
||||
for (short int j = 0; j < 10; j++)
|
||||
{
|
||||
if ( (time(NULL) - call_matrix[j][5]) < 9999)
|
||||
if ( ((time(NULL) - call_matrix[9-j][5]) < 9999) )
|
||||
//if (1 == 1)
|
||||
{
|
||||
printw ("| #%d %s ", 6-j, SyncTypes[call_matrix[j][0]]);
|
||||
printw ("| #%d %s ", j, SyncTypes[call_matrix[9-j][0]]);
|
||||
if (lls == 8 || lls == 9 || lls == 16 || lls == 17)
|
||||
{
|
||||
printw ("RAN [%2d] ", call_matrix[j][1]);
|
||||
printw ("RAN [%2d] ", call_matrix[9-j][1]);
|
||||
}
|
||||
if (lls == 0 || lls == 1 || lls == 11 || lls == 13) //P25 P1 and DMR Voice
|
||||
{
|
||||
printw ("TID [%2d] ", call_matrix[j][1]);
|
||||
printw ("TID [%2d] ", call_matrix[9-j][1]);
|
||||
}
|
||||
|
||||
printw ("RID [%4d] ", call_matrix[j][2]);
|
||||
printw ("RID [%4d] ", call_matrix[9-j][2]);
|
||||
//printw ("S %d - ", call_matrix[j][3]);
|
||||
if (call_matrix[j][0] == 0 || call_matrix[j][0] == 1) //P25P1 Voice
|
||||
if (call_matrix[9-j][0] == 0 || call_matrix[9-j][0] == 1) //P25P1 Voice
|
||||
{
|
||||
printw ("NAC [0x%X] ", call_matrix[j][4]);
|
||||
printw ("NAC [0x%X] ", call_matrix[9-j][4]);
|
||||
}
|
||||
if (call_matrix[j][0] == 12 || call_matrix[j][0] == 13) //DMR Voice Types
|
||||
if (call_matrix[9-j][0] == 12 || call_matrix[9-j][0] == 13 || call_matrix[9-j][0] == 10 || call_matrix[9-j][0] == 11 ) //DMR Voice Types
|
||||
{
|
||||
printw ("DCC [%d] ", call_matrix[j][4]);
|
||||
printw ("DCC [%d] ", call_matrix[9-j][4]);
|
||||
}
|
||||
printw ("%d secs ago\n", time(NULL) - call_matrix[j][5]);
|
||||
printw ("%d secs ago\n", time(NULL) - call_matrix[9-j][5]);
|
||||
}
|
||||
//printw("\n");
|
||||
}
|
||||
printw ("------------------------------------------------------------------------------");
|
||||
printw ("------------------------------------------------------------------------------\n");
|
||||
attroff(COLOR_PAIR(4)); //cyan for history
|
||||
//put sync type at very bottom
|
||||
//printw ("%s %s\n", state->ftype, state->fsubtype); //some ftype strings have extra spaces in them
|
||||
|
|
@ -425,7 +478,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||
|
||||
void ncursesClose ()
|
||||
{
|
||||
erase();
|
||||
refresh();
|
||||
//erase();
|
||||
//refresh();
|
||||
endwin();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,5 +103,5 @@ resetState (dsd_state * state)
|
|||
// state->debug_label_imbe_file = NULL;
|
||||
//#endif
|
||||
|
||||
initialize_p25_heuristics(&state->p25_heuristics); //see if we want to re-init this or not, currently seems to cause memory leak when running over and over
|
||||
initialize_p25_heuristics(&state->p25_heuristics); //see if we want to re-init this or not, currently seems to cause memory leak when running over and over, mitigated with a reset flag
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue