WIP: YSF Decoding; #143

This commit is contained in:
lwvmobile
2023-06-29 18:07:43 -04:00
parent 4feb21cf0a
commit 3be8aacf77
8 changed files with 1296 additions and 267 deletions

View File

@@ -706,6 +706,20 @@ typedef struct
//Upsampled Audio Smoothing //Upsampled Audio Smoothing
uint8_t audio_smoothing; uint8_t audio_smoothing;
//YSF Fusion Call Strings and Info
uint8_t ysf_dt; //data type -- VD1, VD2, Full Rate, etc.
uint8_t ysf_fi; //frame information -- HC, CC, TC
uint8_t ysf_cm; //group or private call
char ysf_tgt[11];
char ysf_src[11];
char ysf_upl[11];
char ysf_dnl[11];
char ysf_rm1[6];
char ysf_rm2[6];
char ysf_rm3[6];
char ysf_rm4[6];
char ysf_txt[21][21]; //text storage blocks
} dsd_state; } dsd_state;
/* /*

View File

@@ -264,18 +264,18 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
} }
else if ((state->synctype == 1) || (state->synctype == 3) || (state->synctype == 5) || else if ((state->synctype == 1) || (state->synctype == 3) || (state->synctype == 5) ||
(state->synctype == 9) || (state->synctype == 11) || (state->synctype == 13) || (state->synctype == 31) || (state->synctype == 11) || (state->synctype == 13) ||
(state->synctype == 17) || (state->synctype == 29) || (state->synctype == 36) ) (state->synctype == 17) || (state->synctype == 29) || (state->synctype == 36) )
{ {
// 1 -P25p1 // 1 -P25p1
// 3 -X2-TDMA (inverted signal voice frame) // 3 -X2-TDMA (inverted signal voice frame)
// 5 -X2-TDMA (inverted signal data frame) // 5 -X2-TDMA (inverted signal data frame)
// 9 -NXDN (inverted voice frame)
// 11 -DMR (inverted signal voice frame) // 11 -DMR (inverted signal voice frame)
// 13 -DMR (inverted signal data frame) // 13 -DMR (inverted signal data frame)
// 17 -NXDN (inverted data frame) // 17 -NXDN (inverted data frame)
// 29 -NXDN (inverted FSW) // 29 -NXDN (inverted FSW)
// 31 -YSF
// 36 -P25p2 // 36 -P25p2
int valid; int valid;
@@ -340,6 +340,7 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
// 12 +DMR (non inverted signal voice frame) // 12 +DMR (non inverted signal voice frame)
// 16 +NXDN (non inverted data frame) // 16 +NXDN (non inverted data frame)
// 28 +NXND (FSW) // 28 +NXND (FSW)
// 30 +YSF
// 35 +p25p2 // 35 +p25p2
int valid; int valid;

View File

@@ -290,13 +290,7 @@ processFrame (dsd_opts * opts, dsd_state * state)
//ysf //ysf
else if ((state->synctype == 30) || (state->synctype == 31)) else if ((state->synctype == 30) || (state->synctype == 31))
{ {
//Do stuff //relocate MBEout to inside frame handling -- Not Working Currently for YSF
//fprintf(stderr, "YSF Sync! \n");
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
//openMbeOutFile (opts, state);
}
//sprintf(state->fsubtype, " VOICE ");
processYSF(opts, state); processYSF(opts, state);
return; return;
} }

View File

@@ -228,13 +228,17 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
{ {
t_max = 10; t_max = 10;
} }
//else if dPMR //dPMR
else if (opts->frame_dpmr == 1) else if (opts->frame_dpmr == 1)
{ {
t_max = 12; //based on Frame_Sync_2 pattern t_max = 12; //based on Frame_Sync_2 pattern
} }
//if Phase 2 (or YSF in future), then only 19 else if (opts->frame_ysf == 1)
else if (state->lastsynctype == 35 || state->lastsynctype == 36) //P2 {
t_max = 20; //20 on YSF
}
//if Phase 2, then only 19
else if (state->lastsynctype == 35 || state->lastsynctype == 36 )
{ {
t_max = 19; //Phase 2 S-ISCH is only 19 t_max = 19; //Phase 2 S-ISCH is only 19
} }
@@ -573,24 +577,20 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
} }
} }
//YSF sync //YSF sync
strncpy(synctest20, (synctest_p - 19), 20); //double check make sure this is right strncpy(synctest20, (synctest_p - 19), 20);
if(opts->frame_ysf == 1) //(opts->frame_ysf == 1 if(opts->frame_ysf == 1) //(opts->frame_ysf == 1
{ {
if (0 == 0) //opts->inverted_ysf == 0 if (0 == 0) //opts->inverted_ysf == 0
{ {
if (strcmp(synctest20, FUSION_SYNC) == 0) if (strcmp(synctest20, FUSION_SYNC) == 0)
{ {
printFrameSync (opts, state, "+YSF ", synctest_pos + 1, modulation);
state->carrier = 1; state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2; state->min = ((state->min) + lmin) / 2;
fprintf (stderr, "\nYSF FUSION SYNC \n"); opts->inverted_ysf = 0;
opts->inverted_ysf = 0; //should we set this here?
state->lastsynctype = 30; state->lastsynctype = 30;
if ( opts->monitor_input_audio == 1)
{
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (30); return (30);
} }
} }
@@ -601,17 +601,13 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
{ {
if (strcmp(synctest20, INV_FUSION_SYNC) == 0) if (strcmp(synctest20, INV_FUSION_SYNC) == 0)
{ {
printFrameSync (opts, state, "-YSF ", synctest_pos + 1, modulation);
state->carrier = 1; state->carrier = 1;
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2; state->min = ((state->min) + lmin) / 2;
fprintf (stderr, "\nINVERTED YSF FUSION SYNC \n"); opts->inverted_ysf = 1;
opts->inverted_ysf = 1; //should we set this here?
state->lastsynctype = 31; state->lastsynctype = 31;
if ( opts->monitor_input_audio == 1)
{
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (31); return (31);
} }
} }

View File

@@ -447,6 +447,20 @@ noCarrier (dsd_opts * opts, dsd_state * state)
sprintf (state->dpmr_caller_id, "%s", " "); sprintf (state->dpmr_caller_id, "%s", " ");
sprintf (state->dpmr_target_id, "%s", " "); sprintf (state->dpmr_target_id, "%s", " ");
//YSF Fusion Call Strings
sprintf (state->ysf_tgt, "%s", " "); //10 spaces
sprintf (state->ysf_src, "%s", " "); //10 spaces
sprintf (state->ysf_upl, "%s", " "); //10 spaces
sprintf (state->ysf_dnl, "%s", " "); //10 spaces
sprintf (state->ysf_rm1, "%s", " "); //5 spaces
sprintf (state->ysf_rm2, "%s", " "); //5 spaces
sprintf (state->ysf_rm3, "%s", " "); //5 spaces
sprintf (state->ysf_rm4, "%s", " "); //5 spaces
memset (state->ysf_txt, 0, sizeof(state->ysf_txt));
state->ysf_dt = 9;
state->ysf_fi = 9;
state->ysf_cm = 9;
} //nocarrier } //nocarrier
void void
@@ -1013,6 +1027,21 @@ initState (dsd_state * state)
sprintf (state->dpmr_caller_id, "%s", " "); sprintf (state->dpmr_caller_id, "%s", " ");
sprintf (state->dpmr_target_id, "%s", " "); sprintf (state->dpmr_target_id, "%s", " ");
//YSF Fusion Call Strings
sprintf (state->ysf_tgt, "%s", " "); //10 spaces
sprintf (state->ysf_src, "%s", " "); //10 spaces
sprintf (state->ysf_upl, "%s", " "); //10 spaces
sprintf (state->ysf_dnl, "%s", " "); //10 spaces
sprintf (state->ysf_rm1, "%s", " "); //5 spaces
sprintf (state->ysf_rm2, "%s", " "); //5 spaces
sprintf (state->ysf_rm3, "%s", " "); //5 spaces
sprintf (state->ysf_rm4, "%s", " "); //5 spaces
memset (state->ysf_txt, 0, sizeof(state->ysf_txt));
state->ysf_dt = 9;
state->ysf_fi = 9;
state->ysf_cm = 9;
} //init_state } //init_state
void void
@@ -1101,6 +1130,7 @@ usage ()
printf (" -fn Decode only NXDN96* (12.5 kHz)\n"); printf (" -fn Decode only NXDN96* (12.5 kHz)\n");
printf (" -fp Decode only EDACS/ProVoice*\n"); printf (" -fp Decode only EDACS/ProVoice*\n");
printf (" -fm Decode only dPMR*\n"); printf (" -fm Decode only dPMR*\n");
printf (" -fy Decode only YSF*\n");
printf (" -l Disable DMR, dPMR, and NXDN input filtering\n"); printf (" -l Disable DMR, dPMR, and NXDN input filtering\n");
printf (" -u <num> Unvoiced speech quality (default=3)\n"); printf (" -u <num> Unvoiced speech quality (default=3)\n");
printf (" -xx Expect non-inverted X2-TDMA signal\n"); printf (" -xx Expect non-inverted X2-TDMA signal\n");
@@ -1895,8 +1925,6 @@ main (int argc, char **argv)
opts.frame_dpmr = 0; opts.frame_dpmr = 0;
opts.frame_provoice = 0; opts.frame_provoice = 0;
opts.frame_ysf = 1; opts.frame_ysf = 1;
state.samplesPerSymbol = 20; //10
state.symbolCenter = 10;
opts.mod_c4fm = 1; opts.mod_c4fm = 1;
opts.mod_qpsk = 0; opts.mod_qpsk = 0;
opts.mod_gfsk = 0; opts.mod_gfsk = 0;
@@ -1907,8 +1935,7 @@ main (int argc, char **argv)
state.dmr_stereo = 0; state.dmr_stereo = 0;
opts.dmr_mono = 0; opts.dmr_mono = 0;
sprintf (opts.output_name, "YSF"); sprintf (opts.output_name, "YSF");
fprintf (stderr,"Setting symbol rate to 2400 / second\n"); fprintf (stderr,"Decoding only YSF frames. \n");
fprintf (stderr,"Decoding only YSF frames.\nNot working yet!\n");
} }
else if (optarg[0] == '2') else if (optarg[0] == '2')
{ {

View File

@@ -85,7 +85,7 @@ char * SyncTypes[44] = {
"NXDN", "NXDN",
"NXDN", "NXDN",
"YSF", //30 "YSF", //30
"YSF", "YSF", //31
"DMR", "DMR",
"DMR", "DMR",
"DMR", "DMR",
@@ -338,7 +338,8 @@ char *choices[] = {
"Decode dPMR", "Decode dPMR",
"Decode NXDN48", "Decode NXDN48",
"Decode NXDN96", "Decode NXDN96",
"Decode DMR Stereo", //was X2-TDMA* "Decode DMR TDMA",
"Decode YSF FUSION",
"Toggle Signal Inversion", "Toggle Signal Inversion",
"Key Entry", "Key Entry",
"Reset Call History", "Reset Call History",
@@ -557,7 +558,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
} }
//Input Output Options //Input Output Options
if (choice == 17) if (choice == 18)
{ {
//test making a new window while other window is open //test making a new window while other window is open
test_win = newwin(HEIGHT-1, WIDTH+9, starty+5, startx+5); test_win = newwin(HEIGHT-1, WIDTH+9, starty+5, startx+5);
@@ -1086,7 +1087,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
} }
//Privacy Key Entry //Privacy Key Entry
if (choice == 13) if (choice == 14)
{ {
state->payload_keyid = 0; state->payload_keyid = 0;
state->payload_keyidR = 0; state->payload_keyidR = 0;
@@ -1539,6 +1540,32 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
//opts->unmute_encrypted_p25 = 0; //opts->unmute_encrypted_p25 = 0;
} }
if (choice == 12) if (choice == 12)
{
//Decode YSF Fusion
// resetState (state); //use sparingly, may cause memory leak
state->samplesPerSymbol = 10;
state->symbolCenter = 4;
sprintf (opts->output_name, "YSF");
opts->dmr_mono = 0;
opts->dmr_stereo = 0; //this value is the end user option
state->dmr_stereo = 0; //this values toggles on and off depending on voice or data handling
opts->pulse_digi_rate_out = 48000;
opts->pulse_digi_out_channels = 1;
opts->frame_dstar = 0;
opts->frame_x2tdma = 0;
opts->frame_p25p1 = 0;
opts->frame_nxdn48 = 0;
opts->frame_nxdn96 = 0;
opts->frame_dmr = 0;
opts->frame_dpmr = 0;
opts->frame_provoice = 0;
opts->frame_ysf = 1;
opts->mod_c4fm = 1;
opts->mod_qpsk = 0;
opts->mod_gfsk = 0;
state->rf_mod = 0;
}
if (choice == 13)
{ {
//Set all signal for inversion or uninversion //Set all signal for inversion or uninversion
if (opts->inverted_dmr == 0) if (opts->inverted_dmr == 0)
@@ -1557,7 +1584,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
} }
} }
if (choice == 14) //reset call history (usually if janky output when switching modes) if (choice == 15) //reset call history (usually if janky output when switching modes)
{ {
for (short int k = 0; k <= 9; k++) for (short int k = 0; k <= 9; k++)
{ {
@@ -1582,7 +1609,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
state->lasttgR = 0; state->lasttgR = 0;
} }
if (choice == 15) //toggle payload printing if (choice == 16) //toggle payload printing
{ {
if (opts->payload == 0) if (opts->payload == 0)
{ {
@@ -1595,7 +1622,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
fprintf(stderr, "Payload Off\n"); fprintf(stderr, "Payload Off\n");
} }
} }
if (choice == 16) if (choice == 17)
{ {
//hardset P2 WACN, SYSID, and NAC //hardset P2 WACN, SYSID, and NAC
entry_win = newwin(6, WIDTH+16, starty+10, startx+10); entry_win = newwin(6, WIDTH+16, starty+10, startx+10);
@@ -1648,7 +1675,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
} }
if (choice == 18) if (choice == 19)
{ {
short int lrrpchoice = 0; short int lrrpchoice = 0;
entry_win = newwin(10, WIDTH+16, starty+10, startx+10); entry_win = newwin(10, WIDTH+16, starty+10, startx+10);
@@ -1714,7 +1741,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
opts->lrrp_out_file[0] = 0; opts->lrrp_out_file[0] = 0;
} }
} }
if (choice == 19) if (choice == 20)
{ {
ncursesClose(); ncursesClose();
//cleanup_rtlsdr_stream(); //cleanup_rtlsdr_stream();
@@ -2409,6 +2436,66 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
} }
} }
//YSF
if (lls == 30 || lls == 31)
{
// printw ("\n");
printw ("| ");
printw ("Yaesu Fusion - ");
//insert data type and frame information
if (state->ysf_dt == 0) printw("Voice/Data T1 ");
if (state->ysf_dt == 1) printw("Data Full Rate");
if (state->ysf_dt == 2) printw("Voice/Data T2 ");
if (state->ysf_dt == 3) printw("V/W Full Rate");
printw (" ");
if (state->ysf_cm == 0) printw("Group/CQ ");
if (state->ysf_cm == 3) printw("Private ");
if (state->ysf_cm == 1) printw("Reserved ");
if (state->ysf_cm == 2) printw("Reserved ");
if (state->ysf_fi == 0) printw("HC ");
if (state->ysf_fi == 1) printw("CC ");
if (state->ysf_fi == 2) printw("TC ");
if (state->ysf_fi == 3) printw("XX ");
printw ("\n");
printw ("| ");
printw ("TGT: %s ", state->ysf_tgt);
printw ("SRC: %s ", state->ysf_src);
printw ("\n");
printw ("| ");
printw ("UPL: %s ", state->ysf_upl);
printw ("DNL: %s ", state->ysf_dnl);
printw ("\n");
printw ("| ");
printw ("RM1: %s ", state->ysf_rm1);
printw ("RM2: %s ", state->ysf_rm2);
printw ("\n");
printw ("| ");
printw ("RM3: %s ", state->ysf_rm3);
printw ("RM4: %s ", state->ysf_rm4);
//these texts can get pretty long and out of sorts, and lots of 0x20 spaces
//just going to leave these to only be in the console output
// printw ("\n");
// printw ("| ");
// printw ("TXT: ");
// for (i = 4; i < 8; i++)
// {
// for (int j = 0; j < 20; j++)
// {
// //no spaces and no asterisks
// if (state->ysf_txt[i][j] != 0x2A)
// printw ("%c", state->ysf_txt[i][j]);
// }
// // printw (" "); //just a single space between each 'block'
// }
printw ("\n");
}
//NXDN //NXDN
if (lls == 28 || lls == 29) if (lls == 28 || lls == 29)
{ {

View File

@@ -277,7 +277,8 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
if (opts->use_cosine_filter) if (opts->use_cosine_filter)
{ {
if ( (state->lastsynctype >= 10 && state->lastsynctype <= 13) || state->lastsynctype == 32 || state->lastsynctype == 33 || state->lastsynctype == 34) if ( (state->lastsynctype >= 10 && state->lastsynctype <= 13) || state->lastsynctype == 32 || state->lastsynctype == 33
|| state->lastsynctype == 34 || state->lastsynctype == 30 || state->lastsynctype == 31)
{ {
sample = dmr_filter(sample); sample = dmr_filter(sample);
} }

1363
src/ysf.c

File diff suppressed because it is too large Load Diff