mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-13 17:27:21 -05:00
NCurses and NXDN Updates
NCurses Terminal in pretty good shape, good enough for testing NXDN decodes RAN and RID now (from LEH)
This commit is contained in:
@@ -28,13 +28,18 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
|
||||
char cachdata[13];
|
||||
char cc[5];
|
||||
char bursttype[5];
|
||||
int dcc_buf;
|
||||
|
||||
#ifdef DMR_DUMP
|
||||
int k;
|
||||
char syncbits[49];
|
||||
char cachbits[25];
|
||||
#endif
|
||||
|
||||
cc[0]=0;
|
||||
cc[1]=0;
|
||||
cc[2]=0;
|
||||
cc[3]=0; //initialize with zeroes to prevent segfault down below
|
||||
state->dmr_color_code = 0; //reset
|
||||
cc[4] = 0;
|
||||
bursttype[4] = 0;
|
||||
|
||||
@@ -95,8 +100,14 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
dibit = (dibit ^ 2);
|
||||
}
|
||||
cc[0] = (1 & (dibit >> 1)) + 48; // bit 1
|
||||
cc[1] = (1 & dibit) + 48; // bit 0
|
||||
//c[0] = (1 & (dibit >> 1)) + 48; // bit 1
|
||||
//cc[1] = (1 & dibit) + 48; // bit 0
|
||||
cc[0] = (1 & (dibit >> 1)); // bit 1
|
||||
cc[1] = (1 & dibit); // bit 0
|
||||
dcc_buf = 0;
|
||||
//dcc_buf = (1 & (dibit >> 1)) | (1 & dibit);
|
||||
dcc_buf = ((1 & (dibit >> 1)) + 48) | ((1 & dibit) + 48);
|
||||
|
||||
|
||||
dibit = *dibit_p;
|
||||
dibit_p++;
|
||||
@@ -104,8 +115,20 @@ processDMRdata (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
dibit = (dibit ^ 2);
|
||||
}
|
||||
cc[2] = (1 & (dibit >> 1)) + 48; // bit 1
|
||||
cc[3] = (1 & dibit) + 48; // bit 0
|
||||
//cc[2] = (1 & (dibit >> 1)) + 48; // bit 1
|
||||
//cc[3] = (1 & dibit) + 48; // bit 0
|
||||
cc[2] = (1 & (dibit >> 1)); // bit 1
|
||||
cc[3] = (1 & dibit); // bit 0
|
||||
|
||||
dcc_buf = dcc_buf << 2;
|
||||
//dcc_buf = (1 & (dibit >> 1)) | (1 & dibit);
|
||||
dcc_buf = ((1 & (dibit >> 1)) + 48) | ((1 & dibit) + 48);
|
||||
|
||||
//state->dmr_color_code = dcc_buf;
|
||||
state->dmr_color_code = (unsigned int)((cc[0] << 3) + (cc[1] << 2) + (cc[2] << 1) + cc[3]);
|
||||
//cc[2] = (1 & (dibit >> 1)); // bit 1
|
||||
//cc[3] = (1 & dibit); // bit 0
|
||||
|
||||
|
||||
dibit = *dibit_p;
|
||||
dibit_p++;
|
||||
|
||||
@@ -358,6 +358,61 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
|
||||
}
|
||||
|
||||
state->last_dibit = dibit;
|
||||
//test loading up a shift register and printing it to stderr
|
||||
//di-bit shift register for hex values
|
||||
//check for which dibit is equal to which half-nibble
|
||||
if (dibit == 0){state->hexbuf = 0x0;} //+1
|
||||
if (dibit == 1){state->hexbuf = 0x1;} //+3
|
||||
if (dibit == 2){state->hexbuf = 0x2;} //-1
|
||||
if (dibit == 3){state->hexbuf = 0x3;} //-3
|
||||
state->sr_0 = (state->sr_0 << 2) | (state->sr_1 >> 62);
|
||||
state->sr_1 = (state->sr_1 << 2) | (state->sr_2 >> 62);
|
||||
state->sr_2 = (state->sr_2 << 2) | (state->sr_3 >> 62);
|
||||
state->sr_3 = (state->sr_3 << 2) | (state->sr_4 >> 62);
|
||||
state->sr_4 = (state->sr_4 << 2) | (state->sr_5 >> 62);
|
||||
state->sr_5 = (state->sr_5 << 2) | (state->sr_6 >> 62);
|
||||
state->sr_6 = state->sr_6 << 2;
|
||||
state->sr_6 |= state->hexbuf;
|
||||
if (1 == 2) //disable this later on
|
||||
{
|
||||
fprintf (stderr, "\nsr_0 = %16llX \n", state->sr_0);
|
||||
fprintf (stderr, "sr_1 = %16llX \n", state->sr_1);
|
||||
fprintf (stderr, "sr_2 = %16llX \n", state->sr_2);
|
||||
fprintf (stderr, "sr_3 = %16llX \n", state->sr_3);
|
||||
fprintf (stderr, "sr_4 = %16llX \n", state->sr_4);
|
||||
fprintf (stderr, "sr_5 = %16llX \n", state->sr_5);
|
||||
fprintf (stderr, "sr_6 = %16llX \n", state->sr_6);
|
||||
/*
|
||||
printw ("sr_0 = %16llX \n", sr_0);
|
||||
printw ("sr_1 = %16llX \n", sr_1);
|
||||
printw ("sr_2 = %16llX \n", sr_2);
|
||||
printw ("sr_3 = %16llX \n", sr_3);
|
||||
printw ("sr_4 = %16llX \n", sr_4);
|
||||
printw ("sr_5 = %16llX \n", sr_5);
|
||||
printw ("sr_6 = %16llX \n", sr_6);
|
||||
*/
|
||||
}
|
||||
|
||||
if ( state->sr_5 & 0xFFFFF == 0xDDF5D) //disable this later on
|
||||
{
|
||||
fprintf (stderr, "\nsr_0 = %16llX \n", state->sr_0);
|
||||
fprintf (stderr, "sr_1 = %16llX \n", state->sr_1);
|
||||
fprintf (stderr, "sr_2 = %16llX \n", state->sr_2);
|
||||
fprintf (stderr, "sr_3 = %16llX \n", state->sr_3);
|
||||
fprintf (stderr, "sr_4 = %16llX \n", state->sr_4);
|
||||
fprintf (stderr, "sr_5 = %16llX \n", state->sr_5);
|
||||
fprintf (stderr, "sr_6 = %16llX \n", state->sr_6);
|
||||
/*
|
||||
printw ("sr_0 = %16llX \n", sr_0);
|
||||
printw ("sr_1 = %16llX \n", sr_1);
|
||||
printw ("sr_2 = %16llX \n", sr_2);
|
||||
printw ("sr_3 = %16llX \n", sr_3);
|
||||
printw ("sr_4 = %16llX \n", sr_4);
|
||||
printw ("sr_5 = %16llX \n", sr_5);
|
||||
printw ("sr_6 = %16llX \n", sr_6);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
*state->dibit_buf_p = dibit;
|
||||
state->dibit_buf_p++;
|
||||
|
||||
@@ -78,10 +78,10 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
||||
state->minref = state->min;
|
||||
}
|
||||
|
||||
if ((state->synctype == 8) || (state->synctype == 9)) //lets make this NOT do this...maybe...
|
||||
if ((state->synctype == 8) || (state->synctype == 9)) //NXDN Voice
|
||||
{
|
||||
//state->rf_mod = 2; //wrong type of modulation HERE HERE
|
||||
//state->nac = 0;
|
||||
state->nac = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lasttg = 0;
|
||||
if (opts->errorbars == 1)
|
||||
@@ -89,7 +89,7 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
||||
if (opts->verbose > 0)
|
||||
{
|
||||
level = (int) state->max / 164;
|
||||
fprintf (stderr,"inlvl: %2i%% ", level);
|
||||
fprintf (stderr, "inlvl: %2i%% ", level);
|
||||
}
|
||||
}
|
||||
state->nac = 0;
|
||||
@@ -101,10 +101,10 @@ processFrame (dsd_opts * opts, dsd_state * state)
|
||||
processNXDNVoice (opts, state);
|
||||
return;
|
||||
}
|
||||
else if ((state->synctype == 16) || (state->synctype == 17))
|
||||
else if ((state->synctype == 16) || (state->synctype == 17)) //NXDN Data
|
||||
{
|
||||
//state->rf_mod = 2;
|
||||
//state->nac = 0;
|
||||
state->nac = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lasttg = 0;
|
||||
if (opts->errorbars == 1)
|
||||
|
||||
571
src/dsd_frame.c.bkp
Normal file
571
src/dsd_frame.c.bkp
Normal file
@@ -0,0 +1,571 @@
|
||||
/*
|
||||
* Copyright (C) 2010 DSD Author
|
||||
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "dsd.h"
|
||||
#if !defined(NULL)
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#include "p25p1_check_nid.h"
|
||||
|
||||
void
|
||||
printFrameInfo (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
|
||||
int level;
|
||||
|
||||
level = (int) state->max / 164;
|
||||
if (opts->verbose > 0)
|
||||
{
|
||||
fprintf (stderr,"inlvl: %2i%% ", level);
|
||||
}
|
||||
if (state->nac != 0)
|
||||
{
|
||||
fprintf (stderr,"nac: %4X ", state->nac);
|
||||
}
|
||||
|
||||
if (opts->verbose > 1)
|
||||
{
|
||||
fprintf (stderr,"src: %8i ", state->lastsrc);
|
||||
}
|
||||
fprintf (stderr,"tg: %5i ", state->lasttg);
|
||||
}
|
||||
|
||||
void
|
||||
processFrame (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
|
||||
int i, j, dibit;
|
||||
char duid[3];
|
||||
char nac[13];
|
||||
int level;
|
||||
|
||||
char status_0;
|
||||
char bch_code[63];
|
||||
int index_bch_code;
|
||||
unsigned char parity;
|
||||
char v;
|
||||
int new_nac;
|
||||
char new_duid[3];
|
||||
int check_result;
|
||||
|
||||
nac[12] = 0;
|
||||
duid[2] = 0;
|
||||
j = 0;
|
||||
|
||||
if (state->rf_mod == 1)
|
||||
{
|
||||
state->maxref = (int)(state->max * 0.80F);
|
||||
state->minref = (int)(state->min * 0.80F);
|
||||
}
|
||||
else
|
||||
{
|
||||
state->maxref = state->max;
|
||||
state->minref = state->min;
|
||||
}
|
||||
|
||||
if ((state->synctype == 8) || (state->synctype == 9)) //lets make this NOT do this...maybe...
|
||||
{
|
||||
//state->rf_mod = 2; //wrong type of modulation HERE HERE
|
||||
state->nac = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lasttg = 0;
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
if (opts->verbose > 0)
|
||||
{
|
||||
level = (int) state->max / 164;
|
||||
fprintf (stderr,"inlvl: %2i%% ", level);
|
||||
}
|
||||
}
|
||||
state->nac = 0;
|
||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
sprintf (state->fsubtype, " VOICE ");
|
||||
processNXDNVoice (opts, state);
|
||||
return;
|
||||
}
|
||||
else if ((state->synctype == 16) || (state->synctype == 17))
|
||||
{
|
||||
//state->rf_mod = 2;
|
||||
state->nac = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lasttg = 0;
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
if (opts->verbose > 0)
|
||||
{
|
||||
level = (int) state->max / 164;
|
||||
fprintf (stderr, "inlvl: %2i%% ", level);
|
||||
}
|
||||
}
|
||||
state->nac = 0;
|
||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
sprintf (state->fsubtype, " DATA ");
|
||||
processNXDNData (opts, state);
|
||||
return;
|
||||
}
|
||||
else if ((state->synctype == 6) || (state->synctype == 7))
|
||||
{
|
||||
state->nac = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lasttg = 0;
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
if (opts->verbose > 0)
|
||||
{
|
||||
level = (int) state->max / 164;
|
||||
fprintf (stderr,"inlvl: %2i%% ", level);
|
||||
}
|
||||
}
|
||||
state->nac = 0;
|
||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
sprintf (state->fsubtype, " VOICE ");
|
||||
processDSTAR (opts, state);
|
||||
return;
|
||||
}
|
||||
else if ((state->synctype == 18) || (state->synctype == 19))
|
||||
{
|
||||
state->nac = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lasttg = 0;
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
if (opts->verbose > 0)
|
||||
{
|
||||
level = (int) state->max / 164;
|
||||
fprintf (stderr,"inlvl: %2i%% ", level);
|
||||
}
|
||||
}
|
||||
state->nac = 0;
|
||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
sprintf (state->fsubtype, " DATA ");
|
||||
processDSTAR_HD (opts, state);
|
||||
return;
|
||||
}
|
||||
|
||||
else if ((state->synctype >= 10) && (state->synctype <= 13))
|
||||
{
|
||||
state->nac = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lasttg = 0;
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
if (opts->verbose > 0)
|
||||
{
|
||||
level = (int) state->max / 164;
|
||||
fprintf (stderr,"inlvl: %2i%% ", level);
|
||||
}
|
||||
}
|
||||
if ((state->synctype == 11) || (state->synctype == 12))
|
||||
{
|
||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
sprintf (state->fsubtype, " VOICE ");
|
||||
processDMRvoice (opts, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
closeMbeOutFile (opts, state);
|
||||
state->err_str[0] = 0;
|
||||
processDMRdata (opts, state);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if ((state->synctype >= 2) && (state->synctype <= 5))
|
||||
{
|
||||
state->nac = 0;
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
}
|
||||
if ((state->synctype == 3) || (state->synctype == 4))
|
||||
{
|
||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
sprintf (state->fsubtype, " VOICE ");
|
||||
processX2TDMAvoice (opts, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
closeMbeOutFile (opts, state);
|
||||
state->err_str[0] = 0;
|
||||
processX2TDMAdata (opts, state);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if ((state->synctype == 14) || (state->synctype == 15))
|
||||
{
|
||||
state->nac = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lasttg = 0;
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
if (opts->verbose > 0)
|
||||
{
|
||||
level = (int) state->max / 164;
|
||||
fprintf (stderr,"inlvl: %2i%% ", level);
|
||||
}
|
||||
}
|
||||
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
sprintf (state->fsubtype, " VOICE ");
|
||||
processProVoice (opts, state);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read the NAC, 12 bits
|
||||
j = 0;
|
||||
index_bch_code = 0;
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
|
||||
v = 1 & (dibit >> 1); // bit 1
|
||||
nac[j] = v + '0';
|
||||
j++;
|
||||
bch_code[index_bch_code] = v;
|
||||
index_bch_code++;
|
||||
|
||||
v = 1 & dibit; // bit 0
|
||||
nac[j] = v + '0';
|
||||
j++;
|
||||
bch_code[index_bch_code] = v;
|
||||
index_bch_code++;
|
||||
}
|
||||
state->nac = strtol (nac, NULL, 2);
|
||||
|
||||
// Read the DUID, 4 bits
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
duid[i] = dibit + '0';
|
||||
|
||||
bch_code[index_bch_code] = 1 & (dibit >> 1); // bit 1
|
||||
index_bch_code++;
|
||||
bch_code[index_bch_code] = 1 & dibit; // bit 0
|
||||
index_bch_code++;
|
||||
}
|
||||
|
||||
// Read the BCH data for error correction of NAC and DUID
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
|
||||
bch_code[index_bch_code] = 1 & (dibit >> 1); // bit 1
|
||||
index_bch_code++;
|
||||
bch_code[index_bch_code] = 1 & dibit; // bit 0
|
||||
index_bch_code++;
|
||||
}
|
||||
// Intermission: read the status dibit
|
||||
status_0 = getDibit (opts, state) + '0';
|
||||
// ... continue reading the BCH error correction data
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
|
||||
bch_code[index_bch_code] = 1 & (dibit >> 1); // bit 1
|
||||
index_bch_code++;
|
||||
bch_code[index_bch_code] = 1 & dibit; // bit 0
|
||||
index_bch_code++;
|
||||
}
|
||||
|
||||
// Read the parity bit
|
||||
dibit = getDibit (opts, state);
|
||||
bch_code[index_bch_code] = 1 & (dibit >> 1); // bit 1
|
||||
parity = (1 & dibit); // bit 0
|
||||
|
||||
// Check if the NID is correct
|
||||
check_result = check_NID (bch_code, &new_nac, new_duid, parity);
|
||||
if (check_result) {
|
||||
if (new_nac != state->nac) {
|
||||
// NAC fixed by error correction
|
||||
state->nac = new_nac;
|
||||
state->debug_header_errors++;
|
||||
}
|
||||
if (strcmp(new_duid, duid) != 0) {
|
||||
// DUID fixed by error correction
|
||||
//fprintf (stderr,"Fixing DUID %s -> %s\n", duid, new_duid);
|
||||
duid[0] = new_duid[0];
|
||||
duid[1] = new_duid[1];
|
||||
state->debug_header_errors++;
|
||||
}
|
||||
} else {
|
||||
// Check of NID failed and unable to recover its value
|
||||
//fprintf (stderr,"NID error\n");
|
||||
duid[0] = 'E';
|
||||
duid[1] = 'E';
|
||||
state->debug_header_critical_errors++;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp (duid, "00") == 0)
|
||||
{
|
||||
// Header Data Unit
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," HDU\n");
|
||||
}
|
||||
if (opts->mbe_out_dir[0] != 0)
|
||||
{
|
||||
closeMbeOutFile (opts, state);
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
|
||||
state->lastp25type = 2;
|
||||
sprintf (state->fsubtype, " HDU ");
|
||||
processHDU (opts, state);
|
||||
}
|
||||
else if (strcmp (duid, "11") == 0)
|
||||
{
|
||||
// Logical Link Data Unit 1
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," LDU1 ");
|
||||
}
|
||||
if (opts->mbe_out_dir[0] != 0)
|
||||
{
|
||||
if (opts->mbe_out_f == NULL)
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
}
|
||||
state->lastp25type = 1;
|
||||
sprintf (state->fsubtype, " LDU1 ");
|
||||
state->numtdulc = 0;
|
||||
processLDU1 (opts, state);
|
||||
}
|
||||
else if (strcmp (duid, "22") == 0)
|
||||
{
|
||||
// Logical Link Data Unit 2
|
||||
if (state->lastp25type != 1)
|
||||
{
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," Ignoring LDU2 not preceeded by LDU1\n");
|
||||
}
|
||||
state->lastp25type = 0;
|
||||
sprintf (state->fsubtype, " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," LDU2 ");
|
||||
}
|
||||
if (opts->mbe_out_dir[0] != 0)
|
||||
{
|
||||
if (opts->mbe_out_f == NULL)
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
}
|
||||
state->lastp25type = 2;
|
||||
sprintf (state->fsubtype, " LDU2 ");
|
||||
state->numtdulc = 0;
|
||||
processLDU2 (opts, state);
|
||||
}
|
||||
}
|
||||
else if (strcmp (duid, "33") == 0)
|
||||
{
|
||||
// Terminator with subsequent Link Control
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," TDULC\n");
|
||||
}
|
||||
if (opts->mbe_out_dir[0] != 0)
|
||||
{
|
||||
closeMbeOutFile (opts, state);
|
||||
}
|
||||
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
|
||||
state->lasttg = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lastp25type = 0;
|
||||
state->err_str[0] = 0;
|
||||
sprintf (state->fsubtype, " TDULC ");
|
||||
state->numtdulc++;
|
||||
if ((opts->resume > 0) && (state->numtdulc > opts->resume))
|
||||
{
|
||||
resumeScan (opts, state);
|
||||
}
|
||||
processTDULC (opts, state);
|
||||
state->err_str[0] = 0;
|
||||
}
|
||||
else if (strcmp (duid, "03") == 0)
|
||||
{
|
||||
// Terminator without subsequent Link Control
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," TDU\n");
|
||||
}
|
||||
if (opts->mbe_out_dir[0] != 0)
|
||||
{
|
||||
closeMbeOutFile (opts, state);
|
||||
}
|
||||
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
|
||||
state->lasttg = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lastp25type = 0;
|
||||
state->err_str[0] = 0;
|
||||
sprintf (state->fsubtype, " TDU ");
|
||||
|
||||
processTDU (opts, state);
|
||||
}
|
||||
else if (strcmp (duid, "13") == 0)
|
||||
{
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," TSDU\n");
|
||||
}
|
||||
if (opts->resume > 0)
|
||||
{
|
||||
resumeScan (opts, state);
|
||||
}
|
||||
state->lasttg = 0;
|
||||
state->lastsrc = 0;
|
||||
state->lastp25type = 3;
|
||||
sprintf (state->fsubtype, " TSDU ");
|
||||
|
||||
// Now processing NID
|
||||
|
||||
skipDibit (opts, state, 328-25);
|
||||
}
|
||||
else if (strcmp (duid, "30") == 0)
|
||||
{
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," PDU\n");
|
||||
}
|
||||
if (opts->resume > 0)
|
||||
{
|
||||
resumeScan (opts, state);
|
||||
}
|
||||
if (opts->mbe_out_dir[0] != 0)
|
||||
{
|
||||
if (opts->mbe_out_f == NULL)
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
}
|
||||
state->lastp25type = 4;
|
||||
sprintf (state->fsubtype, " PDU ");
|
||||
}
|
||||
// try to guess based on previous frame if unknown type
|
||||
else if (state->lastp25type == 1)
|
||||
{
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr,"(LDU2) ");
|
||||
}
|
||||
if (opts->mbe_out_dir[0] != 0)
|
||||
{
|
||||
if (opts->mbe_out_f == NULL)
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
}
|
||||
//state->lastp25type = 0;
|
||||
// Guess that the state is LDU2
|
||||
state->lastp25type = 2;
|
||||
sprintf (state->fsubtype, "(LDU2) ");
|
||||
state->numtdulc = 0;
|
||||
processLDU2 (opts, state);
|
||||
}
|
||||
else if (state->lastp25type == 2)
|
||||
{
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr,"(LDU1) ");
|
||||
}
|
||||
if (opts->mbe_out_dir[0] != 0)
|
||||
{
|
||||
if (opts->mbe_out_f == NULL)
|
||||
{
|
||||
openMbeOutFile (opts, state);
|
||||
}
|
||||
}
|
||||
//state->lastp25type = 0;
|
||||
// Guess that the state is LDU1
|
||||
state->lastp25type = 1;
|
||||
sprintf (state->fsubtype, "(LDU1) ");
|
||||
state->numtdulc = 0;
|
||||
processLDU1 (opts, state);
|
||||
}
|
||||
else if (state->lastp25type == 3)
|
||||
{
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," (TSDU)\n");
|
||||
}
|
||||
//state->lastp25type = 0;
|
||||
// Guess that the state is TSDU
|
||||
state->lastp25type = 3;
|
||||
sprintf (state->fsubtype, "(TSDU) ");
|
||||
|
||||
// Now processing NID
|
||||
|
||||
skipDibit (opts, state, 328-25);
|
||||
}
|
||||
else if (state->lastp25type == 4)
|
||||
{
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," (PDU)\n");
|
||||
}
|
||||
state->lastp25type = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->lastp25type = 0;
|
||||
sprintf (state->fsubtype, " ");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameInfo (opts, state);
|
||||
fprintf (stderr," duid:%s *Unknown DUID*\n", duid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,10 +185,13 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
while (sync == 0)
|
||||
{
|
||||
//fprintf (stderr,"now=%d\n", now); //okay, so this is incrementing as expected
|
||||
if (opts->use_ncurses_terminal == 1)
|
||||
{
|
||||
ncursesPrinter(opts, state);
|
||||
}
|
||||
if ( opts->monitor_input_audio == 1 && (time(NULL) - now) > 1 ) //okay, still something going on, still doing the read part for some reason
|
||||
{
|
||||
playRawAudio(opts, state); //this is on line 21 in dsd_audio.c
|
||||
//fprintf( stderr, "Farts");
|
||||
}
|
||||
|
||||
t++;
|
||||
@@ -406,7 +409,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, " P25 Phase 1 ");
|
||||
sprintf (state->ftype, "P25 Phase 1");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +P25p1 ", synctest_pos + 1, modulation);
|
||||
@@ -421,7 +424,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, " P25 Phase 1 ");
|
||||
sprintf (state->ftype, "P25 Phase 1");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -P25p1 ", synctest_pos + 1, modulation);
|
||||
@@ -442,7 +445,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
if (opts->inverted_x2tdma == 0)
|
||||
{
|
||||
// data frame
|
||||
sprintf (state->ftype, " X2-TDMA ");
|
||||
sprintf (state->ftype, "X2-TDMA");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +X2-TDMA ", synctest_pos + 1, modulation);
|
||||
@@ -453,7 +456,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
else
|
||||
{
|
||||
// inverted voice frame
|
||||
sprintf (state->ftype, " X2-TDMA ");
|
||||
sprintf (state->ftype, "X2-TDMA");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -X2-TDMA ", synctest_pos + 1, modulation);
|
||||
@@ -476,7 +479,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
if (opts->inverted_x2tdma == 0)
|
||||
{
|
||||
// voice frame
|
||||
sprintf (state->ftype, " X2-TDMA ");
|
||||
sprintf (state->ftype, "X2-TDMA");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +X2-TDMA ", synctest_pos + 1, modulation);
|
||||
@@ -491,7 +494,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
else
|
||||
{
|
||||
// inverted data frame
|
||||
sprintf (state->ftype, " X2-TDMA ");
|
||||
sprintf (state->ftype, "X2-TDMA");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -X2-TDMA ", synctest_pos + 1, modulation);
|
||||
@@ -503,7 +506,8 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
}
|
||||
if (opts->frame_dmr == 1)
|
||||
{
|
||||
if ((strcmp (synctest, DMR_MS_DATA_SYNC) == 0) || (strcmp (synctest, DMR_BS_DATA_SYNC) == 0))
|
||||
if ((strcmp (synctest, DMR_MS_DATA_SYNC) == 0) || (strcmp (synctest, DMR_BS_DATA_SYNC) == 0) )//try this
|
||||
//if ((strncmperr (synctest, DMR_MS_DATA_SYNC, 24, 1) == 0) || (strncmperr (synctest, DMR_MS_DATA_SYNC, 24, 1) == 0))
|
||||
{
|
||||
now = time(NULL);
|
||||
state->carrier = 1;
|
||||
@@ -513,7 +517,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
if (opts->inverted_dmr == 0)
|
||||
{
|
||||
// data frame
|
||||
sprintf (state->ftype, " DMR ");
|
||||
sprintf (state->ftype, "DMR");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +DMR ", synctest_pos + 1, modulation);
|
||||
@@ -524,7 +528,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
else
|
||||
{
|
||||
// inverted voice frame
|
||||
sprintf (state->ftype, " DMR ");
|
||||
sprintf (state->ftype, "DMR");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -DMR ", synctest_pos + 1, modulation);
|
||||
@@ -538,6 +542,8 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
}
|
||||
}
|
||||
if ((strcmp (synctest, DMR_MS_VOICE_SYNC) == 0) || (strcmp (synctest, DMR_BS_VOICE_SYNC) == 0))
|
||||
//if ( strcmp (synctest, DMR_MS_VOICE_SYNC) == 0 || strcmp (synctest, DMR_BS_VOICE_SYNC) == 0 || strcmp (synctest, DMR_DIRECT_MODE_TS1_VOICE_SYNC) == 0 || strcmp (synctest, DMR_DIRECT_MODE_TS2_VOICE_SYNC) == 0 )
|
||||
//if ((strncmperr (synctest, DMR_MS_VOICE_SYNC, 24, 1) == 0) || (strncmperr (synctest, DMR_BS_VOICE_SYNC, 24, 1) == 0))
|
||||
{
|
||||
now = time(NULL);
|
||||
state->carrier = 1;
|
||||
@@ -547,7 +553,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
if (opts->inverted_dmr == 0)
|
||||
{
|
||||
// voice frame
|
||||
sprintf (state->ftype, " DMR ");
|
||||
sprintf (state->ftype, "DMR");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +DMR ", synctest_pos + 1, modulation);
|
||||
@@ -562,7 +568,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
else
|
||||
{
|
||||
// inverted data frame
|
||||
sprintf (state->ftype, " DMR ");
|
||||
sprintf (state->ftype, "DMR");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -DMR ", synctest_pos + 1, modulation);
|
||||
@@ -582,7 +588,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, " ProVoice ");
|
||||
sprintf (state->ftype, "ProVoice");
|
||||
if (opts->errorbars == 1)
|
||||
//if (opts->errorbars == 1 && (time(NULL) - now) > 2 )
|
||||
{
|
||||
@@ -602,7 +608,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, " ProVoice ");
|
||||
sprintf (state->ftype, "ProVoice");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -ProVoice ", synctest_pos + 1, modulation);
|
||||
@@ -634,15 +640,17 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
if (state->samplesPerSymbol == 20)
|
||||
{
|
||||
sprintf (state->ftype, " NXDN48 ");
|
||||
//sprintf (state->ftype, " NXDN48 ");
|
||||
sprintf (state->ftype, "NXDN48"); //get rid of spaces
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +NXDN48 ", synctest_pos + 1, modulation);
|
||||
//printFrameSync (opts, state, " +NXDN48 ", synctest_pos + 1, modulation);
|
||||
printFrameSync (opts, state, " +NXDN48", synctest_pos + 1, modulation);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (state->ftype, " NXDN96 ");
|
||||
sprintf (state->ftype, "NXDN96");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +NXDN96 ", synctest_pos + 1, modulation);
|
||||
@@ -675,15 +683,17 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
if (state->samplesPerSymbol == 20)
|
||||
{
|
||||
sprintf (state->ftype, " NXDN48 ");
|
||||
//sprintf (state->ftype, " NXDN48 ");
|
||||
sprintf (state->ftype, "NXDN48");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -NXDN48 ", synctest_pos + 1, modulation);
|
||||
//printFrameSync (opts, state, " -NXDN48 ", synctest_pos + 1, modulation);
|
||||
printFrameSync (opts, state, " -NXDN48", synctest_pos + 1, modulation);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (state->ftype, " NXDN96 ");
|
||||
sprintf (state->ftype, "NXDN96");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -NXDN96 ", synctest_pos + 1, modulation);
|
||||
@@ -714,15 +724,17 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
if (state->samplesPerSymbol == 20)
|
||||
{
|
||||
sprintf (state->ftype, " NXDN48 ");
|
||||
//sprintf (state->ftype, " NXDN48 ");
|
||||
sprintf (state->ftype, "NXDN48");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +NXDN48 ", synctest_pos + 1, modulation);
|
||||
//printFrameSync (opts, state, " +NXDN48 ", synctest_pos + 1, modulation);
|
||||
printFrameSync (opts, state, " +NXDN48", synctest_pos + 1, modulation);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (state->ftype, " NXDN96 ");
|
||||
sprintf (state->ftype, "NXDN96");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +NXDN96 ", synctest_pos + 1, modulation);
|
||||
@@ -751,10 +763,12 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, " NXDN ");
|
||||
//sprintf (state->ftype, " NXDN ");
|
||||
sprintf (state->ftype, "NXDN");
|
||||
if (state->samplesPerSymbol == 20)
|
||||
{
|
||||
sprintf (state->ftype, " NXDN48 ");
|
||||
sprintf (state->ftype, "NXDN48");
|
||||
//sprintf (state->ftype, "NXDN48");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -NXDN48 ", synctest_pos + 1, modulation);
|
||||
@@ -762,7 +776,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (state->ftype, " NXDN96 ");
|
||||
sprintf (state->ftype, "NXDN96");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -NXDN96 ", synctest_pos + 1, modulation);
|
||||
@@ -792,7 +806,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, " D-STAR ");
|
||||
sprintf (state->ftype, "D-STAR");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +D-STAR ", synctest_pos + 1, modulation);
|
||||
@@ -811,7 +825,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, " D-STAR ");
|
||||
sprintf (state->ftype, "D-STAR");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -D-STAR ", synctest_pos + 1, modulation);
|
||||
@@ -830,7 +844,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, " D-STAR_HD ");
|
||||
sprintf (state->ftype, "D-STAR_HD");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " +D-STAR_HD ", synctest_pos + 1, modulation);
|
||||
@@ -849,7 +863,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, " D-STAR_HD ");
|
||||
sprintf (state->ftype, "D-STAR_HD");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, " -D-STAR_HD ", synctest_pos + 1, modulation);
|
||||
@@ -927,7 +941,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, "(X2-TDMA) ");
|
||||
sprintf (state->ftype, "(X2-TDMA)");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, "(+X2-TDMA) ", synctest_pos + 1, modulation);
|
||||
@@ -945,7 +959,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
state->offset = synctest_pos;
|
||||
state->max = ((state->max) + lmax) / 2;
|
||||
state->min = ((state->min) + lmin) / 2;
|
||||
sprintf (state->ftype, "(DMR) ");
|
||||
sprintf (state->ftype, "(DMR)");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printFrameSync (opts, state, "(-DMR) ", synctest_pos + 1, modulation);
|
||||
|
||||
@@ -293,6 +293,8 @@ initState (dsd_state * state)
|
||||
state->debug_header_errors = 0;
|
||||
state->debug_header_critical_errors = 0;
|
||||
|
||||
state->nxdn_last_ran = 0;
|
||||
|
||||
#ifdef TRACE_DSD
|
||||
state->debug_sample_index = 0;
|
||||
state->debug_label_file = NULL;
|
||||
@@ -787,7 +789,7 @@ main (int argc, char **argv)
|
||||
opts.frame_x2tdma = 1;
|
||||
opts.frame_p25p1 = 1;
|
||||
opts.frame_nxdn48 = 0; //turn it on, doesn't work due to symbol rate difference
|
||||
opts.frame_nxdn96 = 0; //causes false positives, leave on 0
|
||||
opts.frame_nxdn96 = 0; //causes false positives, leave on 0
|
||||
opts.frame_dmr = 1;
|
||||
opts.frame_provoice = 0; //turn it on, doesn't work due to symbol rate difference
|
||||
}
|
||||
@@ -877,7 +879,6 @@ main (int argc, char **argv)
|
||||
opts.mod_qpsk = 0;
|
||||
opts.mod_gfsk = 0; //was 1
|
||||
state.rf_mod = 0; //was 2
|
||||
//fprintf (stderr,"Enabling only GFSK modulation optimizations.\n");
|
||||
fprintf (stderr,"Enabling only C4FM modulation optimizations.\n");
|
||||
fprintf (stderr,"Decoding only NXDN 9600 baud frames.\n");
|
||||
}
|
||||
@@ -890,6 +891,9 @@ main (int argc, char **argv)
|
||||
opts.frame_nxdn96 = 0;
|
||||
opts.frame_dmr = 1;
|
||||
opts.frame_provoice = 0;
|
||||
opts.mod_c4fm = 1; //just a test
|
||||
opts.mod_qpsk = 0;
|
||||
opts.mod_gfsk = 0; //was 1
|
||||
fprintf (stderr,"Decoding only DMR/MOTOTRBO frames.\n");
|
||||
}
|
||||
break;
|
||||
|
||||
142
src/dsd_mbe.c
142
src/dsd_mbe.c
@@ -17,6 +17,8 @@
|
||||
|
||||
#include "dsd.h"
|
||||
|
||||
static void DecipherData(char * Input, char * KeyStream, char * Output, int NbData);
|
||||
|
||||
void
|
||||
playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv)
|
||||
{
|
||||
@@ -73,12 +75,14 @@ playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv)
|
||||
void
|
||||
processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24])
|
||||
{
|
||||
|
||||
//comment out line below should return print back to normal
|
||||
//strncpy (state->err_buf, state->err_str, sizeof(state->err_str)); //right at the very top before err_str gets returned?
|
||||
int i;
|
||||
char imbe_d[88];
|
||||
char ambe_d[49];
|
||||
#ifdef AMBE_PACKET_OUT
|
||||
char ambe_d_str[50];
|
||||
#ifdef AMBE_PACKET_OUT
|
||||
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 88; i++)
|
||||
@@ -117,6 +121,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
|
||||
{
|
||||
mbe_processAmbe3600x2450Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
|
||||
#ifdef AMBE_PACKET_OUT
|
||||
|
||||
for(i=0; i<49; i++) {
|
||||
ambe_d_str[i] = ambe_d[i] + '0';
|
||||
}
|
||||
@@ -124,7 +129,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
|
||||
// print binary string
|
||||
fprintf (stderr, "\n?\t?\t%s\t", ambe_d_str);
|
||||
// print error data
|
||||
fprintf (stderr, "E1: %d; E2: %d; S: %s", state->errs, state->errs2, state->err_str);
|
||||
fprintf (stderr, "E1: %d; E2: %d; S: %s", state->errs, state->errs2, state->err_str);}
|
||||
#endif
|
||||
if (opts->mbe_out_f != NULL)
|
||||
{
|
||||
@@ -134,8 +139,10 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
|
||||
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr, "%s", state->err_str);
|
||||
//printw("%s", state->err_str);
|
||||
//state->err_buf = state->err_str; //make comy to compare, and only print when comparison differs?? THIS HERE HERE
|
||||
//strncpy (state->err_buf, state->err_str, sizeof(state->err_str)); //is this the correct placement for this? want it just before err_str is set?
|
||||
fprintf (stderr, "%s", state->err_str); //this the actual error 'bar' ==== printer, find way to keep this entire string from printing constantly unless err_str changes
|
||||
//fprintf (stderr, "%s", state->err_buf);
|
||||
}
|
||||
|
||||
state->debug_audio_errors += state->errs2;
|
||||
@@ -151,3 +158,128 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
|
||||
playSynthesizedVoice (opts, state);
|
||||
}
|
||||
}
|
||||
|
||||
void processMbeFrameEncrypted (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24], char ambe_keystream[49], char imbe_keystream[88])
|
||||
{
|
||||
|
||||
int i;
|
||||
char imbe_d[88];
|
||||
char ambe_d[49];
|
||||
#ifdef AMBE_PACKET_OUT
|
||||
char ambe_d_str[50];
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 88; i++)
|
||||
{
|
||||
imbe_d[i] = 0;
|
||||
}
|
||||
|
||||
if ((state->synctype == 0) || (state->synctype == 1))
|
||||
{
|
||||
// 0 +P25p1
|
||||
// 1 -P25p1
|
||||
|
||||
mbe_processImbe7200x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe_fr, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
|
||||
|
||||
DecipherData(imbe_d, imbe_keystream, imbe_d, 88);
|
||||
|
||||
if (opts->mbe_out_f != NULL)
|
||||
{
|
||||
saveImbe4400Data (opts, state, imbe_d);
|
||||
}
|
||||
}
|
||||
else if ((state->synctype == 14) || (state->synctype == 15))
|
||||
{
|
||||
mbe_processImbe7100x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe7100_fr, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
|
||||
|
||||
DecipherData(imbe_d, imbe_keystream, imbe_d, 88);
|
||||
|
||||
if (opts->mbe_out_f != NULL)
|
||||
{
|
||||
saveImbe4400Data (opts, state, imbe_d);
|
||||
}
|
||||
}
|
||||
else if ((state->synctype == 6) || (state->synctype == 7))
|
||||
{
|
||||
//mbe_processAmbe3600x2400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
|
||||
|
||||
state->errs = 0;
|
||||
state->errs2 = 0;
|
||||
state->errs = mbe_eccAmbe3600x2400C0 (ambe_fr);
|
||||
mbe_demodulateAmbe3600x2400Data (ambe_fr);
|
||||
state->errs2 = state->errs;
|
||||
state->errs2 += mbe_eccAmbe3600x2400Data (ambe_fr, ambe_d);
|
||||
|
||||
memcpy(state->ambe_ciphered, ambe_d, sizeof(state->ambe_ciphered));
|
||||
DecipherData(ambe_d, ambe_keystream, ambe_d, 49);
|
||||
memcpy(state->ambe_deciphered, ambe_d, sizeof(state->ambe_deciphered));
|
||||
|
||||
mbe_processAmbe2400Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
|
||||
|
||||
if (opts->mbe_out_f != NULL)
|
||||
{
|
||||
saveAmbe2450Data (opts, state, ambe_d);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//mbe_processAmbe3600x2450Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
|
||||
|
||||
state->errs = 0;
|
||||
state->errs2 = 0;
|
||||
state->errs = mbe_eccAmbe3600x2450C0 (ambe_fr);
|
||||
mbe_demodulateAmbe3600x2450Data (ambe_fr);
|
||||
state->errs2 = state->errs;
|
||||
state->errs2 += mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d);
|
||||
|
||||
memcpy(state->ambe_ciphered, ambe_d, sizeof(state->ambe_ciphered));
|
||||
DecipherData(ambe_d, ambe_keystream, ambe_d, 49);
|
||||
memcpy(state->ambe_deciphered, ambe_d, sizeof(state->ambe_deciphered));
|
||||
|
||||
mbe_processAmbe2450Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
|
||||
|
||||
#ifdef AMBE_PACKET_OUT
|
||||
for(i=0; i<49; i++) {
|
||||
ambe_d_str[i] = ambe_d[i] + '0';
|
||||
}
|
||||
ambe_d_str[49] = '\0';
|
||||
// print binary string
|
||||
fprintf(stderr, "\n?\t?\t%s\t", ambe_d_str);
|
||||
// print error data
|
||||
fprintf(stderr, "E1: %d; E2: %d; S: %s", state->errs, state->errs2, state->err_str);
|
||||
#endif
|
||||
if (opts->mbe_out_f != NULL)
|
||||
{
|
||||
saveAmbe2450Data (opts, state, ambe_d);
|
||||
}
|
||||
}
|
||||
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf(stderr, "%s", state->err_str);
|
||||
}
|
||||
|
||||
state->debug_audio_errors += state->errs2;
|
||||
|
||||
processAudio (opts, state);
|
||||
if (opts->wav_out_f != NULL)
|
||||
{
|
||||
writeSynthesizedVoice (opts, state);
|
||||
}
|
||||
|
||||
if (opts->audio_out == 1)
|
||||
{
|
||||
playSynthesizedVoice (opts, state);
|
||||
}
|
||||
}
|
||||
|
||||
/* This function decipher/decrypt data */
|
||||
static void DecipherData(char * Input, char * KeyStream, char * Output, int NbData)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < NbData; i++)
|
||||
{
|
||||
Output[i] = Input[i] ^ KeyStream[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,28 @@
|
||||
|
||||
#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 tg; //last tg
|
||||
int rd; //last rid
|
||||
int rn; //last ran
|
||||
int nc; //nac
|
||||
int src; //last rid? double?
|
||||
int lls = -1; //last last sync type
|
||||
int dcc = 0; //initialize with 0 to prevent core dump
|
||||
int i = 0;
|
||||
char * s0last = " ";
|
||||
char * s1last = " ";
|
||||
char versionstr[25];
|
||||
unsigned long long int call_matrix[33][6]; //0 - sync type; 1 - tg/ran; 2 - rid; 3 - slot; 4 - cc; 5 - time(NULL) ;
|
||||
char * FM_bannerN[9] = {
|
||||
" CTRL + C twice to exit",
|
||||
" ██████╗ ██████╗██████╗ ███████╗███╗ ███╗███████╗",
|
||||
@@ -48,16 +69,16 @@ char * SyncTypes[20] = {
|
||||
"INV_X2TDMA_BS/MS_VOICE_SYNC",
|
||||
"DSTAR_SYNC",
|
||||
"INV_DSTAR_SYNC",
|
||||
"NXDN_BS_VOICE_SYNC", //8
|
||||
"INV_NXDN_BS_VOICE_SYNC", //9
|
||||
"DMR_BS/MS_DATA_SYNC",
|
||||
"INV_DMR_BS/MS_DATA_SYNC",
|
||||
"DMR_BS/MS_VOICE_SYNC",
|
||||
"INV_DMR_BS/MS_VOICE_SYNC",
|
||||
"PROVOICE_SYNC", //14
|
||||
"INV_PROVOICE_SYNC", //15
|
||||
"NXDN_BS_DATA_SYNC", //16
|
||||
"INV_NXDN_BS_DATA_SYNC", //17
|
||||
"NXDN_BS_VOICE_SYNC", //8
|
||||
"INV_NXDN_BS_VOICE_SYNC", //9
|
||||
"DMR_BS/MS_DATA_SYNC", //10
|
||||
"DMR_MS/BS_VOICE_SYNC", //11
|
||||
"DMR_MS/BS_DATA_SYNC", //12
|
||||
"INV_DMR_BS/MS_VOICE_SYNC", //13
|
||||
"PROVOICE_SYNC", //14
|
||||
"INV_PROVOICE_SYNC", //15
|
||||
"NXDN_BS_DATA_SYNC", //16
|
||||
"INV_NXDN_BS_DATA_SYNC", //17
|
||||
"DSTAR_HD",
|
||||
"INV_DSTAR_HD"
|
||||
|
||||
@@ -82,7 +103,7 @@ char * getTimeN(void) //get pretty hh:mm:ss timestamp
|
||||
void ncursesOpen ()
|
||||
{
|
||||
mbe_printVersion (versionstr);
|
||||
setlocale(LC_ALL, "");
|
||||
//setlocale(LC_ALL, "");
|
||||
initscr(); //Initialize NCURSES screen window
|
||||
start_color();
|
||||
init_pair(1, COLOR_YELLOW, COLOR_BLACK); //Yellow/Amber for frame sync/control channel, NV style
|
||||
@@ -92,93 +113,339 @@ void ncursesOpen ()
|
||||
init_pair(5, COLOR_MAGENTA, COLOR_BLACK); //Magenta for no frame sync/signal
|
||||
noecho();
|
||||
cbreak();
|
||||
fprintf (stderr, "Opening NCurses Terminal. \n");
|
||||
//call_matrix[5-i][0] = 0;
|
||||
//call_matrix[5-i][1] = 0;
|
||||
//call_matrix[5-i][2] = 0;
|
||||
//call_matrix[5-i][3] = 0;
|
||||
//call_matrix[5-i][4] = 0;
|
||||
//call_matrix[5-i][5] = time(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
int level;
|
||||
level = (int) state->max / 164;
|
||||
|
||||
//level = (int) state->max / 164;
|
||||
level = 0; //start each cycle with 0
|
||||
erase();
|
||||
//disabling until wide support can be built for LM, etc. $(ncursesw5-config --cflags --libs)
|
||||
//printw ("%s \n", FM_bannerN[0]); //top line in white
|
||||
//attron(COLOR_PAIR(4));
|
||||
//for (short int i = 1; i < 7; i++) { //following lines in cyan
|
||||
//printw("%s \n", FM_bannerN[i]); }
|
||||
//attroff(COLOR_PAIR(4));
|
||||
printw ("%s \n", FM_bannerN[7]); //http link
|
||||
printw ("Digital Speech Decoder: Florida Man Edition\n");
|
||||
printw ("Github Build Version: %s \n", GIT_TAG);
|
||||
printw ("mbelib version %s\n", versionstr);
|
||||
printw ("Time: ");
|
||||
printw ("%s ", getTimeN());
|
||||
if (SyncTypes[state->lastsynctype] != NULL)
|
||||
attron(COLOR_PAIR(4));
|
||||
//for (short int i = 1; i < 7; i++)
|
||||
//{ //following lines in cyan
|
||||
//printw("%s \n", FM_bannerN[i]);
|
||||
//}
|
||||
attroff(COLOR_PAIR(4));
|
||||
printw ("--Build Info------------------------------------------------------------------\n");
|
||||
//printw ("| %s \n", FM_bannerN[7]); //http link
|
||||
printw ("| Digital Speech Decoder: Florida Man Edition\n");
|
||||
printw ("| Github Build Version: %s \n", GIT_TAG);
|
||||
printw ("| mbelib version %s\n", versionstr);
|
||||
printw ("------------------------------------------------------------------------------\n");
|
||||
|
||||
|
||||
if ( (state->lastsynctype == 14 || state->lastsynctype == 15) ) //honestly have no idea how to do this for pV
|
||||
{
|
||||
printw ("%s \n", SyncTypes[state->lastsynctype]);
|
||||
//printw("%s ", state->ftype); //moved to front, some ftype strings have spaces in front of them, and others dont
|
||||
/* Not sure if I'm going to use the error bars yet
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
printw("-"); //AFAIK, errorbars==1 is the internal value for if a system has inverted signal types, not at all misleading
|
||||
}
|
||||
else
|
||||
{
|
||||
printw("+");
|
||||
}
|
||||
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
|
||||
{
|
||||
/* //save just in case
|
||||
call_matrix[0][0] = call_matrix[1][0];
|
||||
call_matrix[0][1] = call_matrix[1][1];
|
||||
call_matrix[0][2] = call_matrix[1][2];
|
||||
call_matrix[0][3] = call_matrix[1][3];
|
||||
call_matrix[0][4] = call_matrix[1][4];
|
||||
call_matrix[0][5] = call_matrix[1][5];
|
||||
|
||||
call_matrix[1][0] = call_matrix[2][0];
|
||||
call_matrix[1][1] = call_matrix[2][1];
|
||||
call_matrix[1][2] = call_matrix[2][2];
|
||||
call_matrix[1][3] = call_matrix[2][3];
|
||||
call_matrix[1][4] = call_matrix[2][4];
|
||||
call_matrix[1][5] = call_matrix[2][5];
|
||||
|
||||
call_matrix[2][0] = call_matrix[3][0];
|
||||
call_matrix[2][1] = call_matrix[3][1];
|
||||
call_matrix[2][2] = call_matrix[3][2];
|
||||
call_matrix[2][3] = call_matrix[3][3];
|
||||
call_matrix[2][4] = call_matrix[3][4];
|
||||
call_matrix[2][5] = call_matrix[3][5];
|
||||
|
||||
call_matrix[3][0] = call_matrix[4][0];
|
||||
call_matrix[3][1] = call_matrix[4][1];
|
||||
call_matrix[3][2] = call_matrix[4][2];
|
||||
call_matrix[3][3] = call_matrix[4][3];
|
||||
call_matrix[3][4] = call_matrix[4][4];
|
||||
call_matrix[3][5] = call_matrix[4][5];
|
||||
|
||||
call_matrix[4][0] = call_matrix[5][0];
|
||||
call_matrix[4][1] = call_matrix[5][1];
|
||||
call_matrix[4][2] = call_matrix[5][2];
|
||||
call_matrix[4][3] = call_matrix[5][3];
|
||||
call_matrix[4][4] = call_matrix[5][4];
|
||||
call_matrix[4][5] = call_matrix[5][5];
|
||||
*/
|
||||
if (1 == 1){ //figure out method that will tell me when is active and when not active, maybe carrier but this doesn't print anyways unless activity
|
||||
attron(COLOR_PAIR(3));
|
||||
}
|
||||
printw ("%s %s\n", state->ftype, state->fsubtype); //some ftype strings have extra spaces in them
|
||||
if (state->lasttg < 0) //triggers compiler warning: comparison between pointer and integer
|
||||
for (short int k = 0; k < 5; k++)
|
||||
{
|
||||
//sprintf(state->ftype, )
|
||||
//state->lasttg = state->ftype; //warning: assignment to ‘int’ from ‘char *
|
||||
state->lasttg = 0;
|
||||
}
|
||||
printw ("TG [%7i] RID [%12i] \n", state->lasttg, state->lastsrc); //variables to fill with info from other system types too
|
||||
//printw ("TG [%s] \n", state->lasttg);
|
||||
//printw ("TDMA activity: %s %s \n", state->slot0light, state->slot1light);
|
||||
printw("In Level: [%2i%%] ", level);
|
||||
printw ("Voice Error [%s] \n", state->err_str); //no idea if this shows anything outside of TDMA or P1 or what
|
||||
if (1 == 1){ //same as above
|
||||
attroff(COLOR_PAIR(3));
|
||||
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 (state->lastsynctype == 8 ||state->lastsynctype == 9 ||state->lastsynctype == 16 ||state->lastsynctype == 17)
|
||||
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 (state->samplesPerSymbol == 20)
|
||||
{
|
||||
//sprintf (state->ftype, " NXDN48 ");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
//printFrameSync (opts, state, " -NXDN48 ", synctest_pos + 1, modulation);
|
||||
printw("NXDN48 ");
|
||||
printw("%s \n", SyncTypes[state->lastsynctype]);
|
||||
printw("%s ", state->ftype);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//sprintf (state->ftype, " NXDN96 ");
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
//printFrameSync (opts, state, " -NXDN96 ", synctest_pos + 1, modulation);
|
||||
printw("NXDN96 ");
|
||||
printw("%s ", SyncTypes[state->lastsynctype]);
|
||||
printw("%s ", state->ftype);
|
||||
}
|
||||
}
|
||||
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] = tg;
|
||||
call_matrix[5][2] = rd;
|
||||
call_matrix[5][3] = 0;
|
||||
call_matrix[5][4] = nc;
|
||||
call_matrix[5][5] = time(NULL);
|
||||
//i++;
|
||||
}
|
||||
//printw ("Time: ");
|
||||
//printw ("%s \n", getTimeN());
|
||||
attron(COLOR_PAIR(4));
|
||||
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);
|
||||
}
|
||||
if (opts->audio_in_type == 1)
|
||||
{
|
||||
printw ("| STDIN - Input\n");
|
||||
}
|
||||
if (opts->audio_in_type == 3)
|
||||
{
|
||||
printw ("| RTL2838 Device #[%d]", opts->rtl_dev_index);
|
||||
printw (" [%i] dB", opts->rtl_gain_value);
|
||||
printw (" [%i] Sq", opts->rtl_squelch_level);
|
||||
printw (" [%i] kHz VFO\n", opts->rtl_bandwidth);
|
||||
printw ("| Freq: [%lld] Hz", opts->rtlsdr_center_freq);
|
||||
printw (" - Tuning available on UDP Port [%i]\n", opts->rtl_udp_port);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (opts->mbe_out_dir[0] != 0)
|
||||
{
|
||||
printw ("| Writing MBE data files to directory %s\n", opts->mbe_out_dir);
|
||||
}
|
||||
if (opts->wav_out_file[0] != 0)
|
||||
{
|
||||
printw ("| Writing audio wav to file %s\n", opts->wav_out_file);
|
||||
}
|
||||
*/
|
||||
|
||||
printw("\n"); //line return
|
||||
printw ("------------------------------------------------------------------------------\n");
|
||||
attroff(COLOR_PAIR(4));
|
||||
|
||||
if (state->carrier == 1){ //figure out method that will tell me when is active and when not active, maybe carrier but this doesn't print anyways unless activity
|
||||
attron(COLOR_PAIR(3));
|
||||
level = (int) state->max / 164; //only update on carrier present
|
||||
}
|
||||
//if (state->carrier == 0){ //figure out method that will tell me when is active and when not active, maybe carrier but this doesn't print anyways unless activity
|
||||
//attron(COLOR_PAIR(1));
|
||||
//0 - sync type; 1 - tg/ran; 2 - rid; 3 - slot; 4 - dcc; 5 - time(NULL) ;
|
||||
//}
|
||||
|
||||
printw ("--Audio Decode----------------------------------------------------------------\n");
|
||||
printw ("| In Level: [%3i%%] \n", level);
|
||||
printw ("| Voice Error: [%i][%i] \n| Error Bars: [%s] \n", state->errs, state->errs2, state->err_str); //
|
||||
printw ("------------------------------------------------------------------------------\n");
|
||||
|
||||
|
||||
printw ("--Call Info-------------------------------------------------------------------\n");
|
||||
if (state->lastsynctype != -1) //not sure if this will be okay
|
||||
{
|
||||
lls = state->lastsynctype;
|
||||
}
|
||||
if (state->nxdn_last_rid > 0 && state->nxdn_last_rid != src);
|
||||
{
|
||||
src = state->nxdn_last_rid;
|
||||
//rn = state->nxdn_last_ran;
|
||||
}
|
||||
if (state->nxdn_last_ran > 0 && state->nxdn_last_rid != rn);
|
||||
{
|
||||
//src = state->nxdn_last_rid;
|
||||
rn = state->nxdn_last_ran;
|
||||
}
|
||||
//if (state->lastsynctype == 8 || state->lastsynctype == 9 || state->lastsynctype == 16 || state->lastsynctype == 17) //change this to NXDN syncs later on
|
||||
if (lls == 8 || lls == 9 || lls == 16 || lls == 17)
|
||||
{
|
||||
//printw ("| RAN: [%02d] \n", state->nxdn_last_ran);
|
||||
printw ("| RAN: [%02d] \n", rn);
|
||||
printw ("| RID: [%d] \n", src); //maybe change to nxdn_last_rid
|
||||
}
|
||||
|
||||
//printw ("Error?: [%i] [%i] \n", state->errs, state->errs2); //what are these?
|
||||
|
||||
if (state->lasttg > 0 && state->lastsrc > 0)
|
||||
{
|
||||
tg = state->lasttg;
|
||||
rd = state->lastsrc;
|
||||
}
|
||||
if (state->nac > 0)
|
||||
{
|
||||
nc = state->nac;
|
||||
}
|
||||
if ((lls == 0 || lls == 1)) //1 for P25 P1 Audio
|
||||
{
|
||||
printw("| TID:[%i] \n| RID:[%i] \n", tg, rd);
|
||||
printw("| NAC: [0x%X] \n", nc);
|
||||
}
|
||||
//if (state->lastsynctype == 12 || state->lastsynctype == 13) //DMR Voice Types
|
||||
if (lls == 11 || lls == 13) //DMR Voice Types
|
||||
{
|
||||
printw ("| DCC: [%i]\n", state->dmr_color_code);
|
||||
//printw ("%s ", state->slot0light);
|
||||
printw ("| SLOT 0 ");
|
||||
if (state->currentslot == 0) //find out how to tell when slot0 has voice
|
||||
{
|
||||
s0last = "Voice";
|
||||
//printw("Voice");
|
||||
}
|
||||
printw ("%s ", s0last);
|
||||
|
||||
//printw ("%s ", state->slot1light);
|
||||
printw ("SLOT 1 ");
|
||||
if (state->currentslot == 1) //find out how to tell when slot1 has voice
|
||||
{
|
||||
s1last = "Voice";
|
||||
//printw("Voice");
|
||||
}
|
||||
printw ("%s \n", s1last);
|
||||
}
|
||||
|
||||
if (state->dmr_color_code > 0 && (lls == 11 || lls == 13) ) //DMR VOice
|
||||
{
|
||||
dcc = state->dmr_color_code;
|
||||
}
|
||||
//if (state->lastsynctype == 10 || state->lastsynctype == 11) //DMR Data Types
|
||||
if (lls == 10 || lls == 11) //DMR Data Types
|
||||
{
|
||||
printw ("| DCC: [%i]\n", dcc);
|
||||
//printw ("%s ", state->slot0light);
|
||||
printw ("| SLOT 0 ");
|
||||
if (state->currentslot == 0) //find out how to tell when slot0 has voice
|
||||
{
|
||||
s0last = "Data ";
|
||||
if (strcmp (state->fsubtype, " Slot idle ") == 0)
|
||||
{
|
||||
s0last = "Idle ";
|
||||
}
|
||||
}
|
||||
printw ("%s ", s0last);
|
||||
//printw ("%s ", state->slot1light);
|
||||
printw ("SLOT 1 ");
|
||||
if (state->currentslot == 1) //find out how to tell when slot1 has voice
|
||||
{
|
||||
s1last = "Data ";
|
||||
if (strcmp (state->fsubtype, " Slot idle ") == 0)
|
||||
{
|
||||
s1last = "Idle ";
|
||||
}
|
||||
}
|
||||
printw ("%s \n", s1last);
|
||||
}
|
||||
if (lls != -1) //is there a synctype 0?
|
||||
{
|
||||
printw ("| %s \n", SyncTypes[lls]);
|
||||
}
|
||||
printw ("------------------------------------------------------------------------------\n");
|
||||
//colors off
|
||||
if (state->carrier == 1){ //same as above
|
||||
attroff(COLOR_PAIR(3));
|
||||
}
|
||||
//if (state->carrier == 0){ //same as above
|
||||
//attroff(COLOR_PAIR(1));
|
||||
//}
|
||||
|
||||
attron(COLOR_PAIR(4)); //cyan for history
|
||||
//add other interesting info to put here
|
||||
//make Call_Matrix
|
||||
//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++)
|
||||
{
|
||||
if ( (time(NULL) - call_matrix[j][5]) < 9999)
|
||||
//if (1 == 1)
|
||||
{
|
||||
printw ("| #%d %s ", 6-j, SyncTypes[call_matrix[j][0]]);
|
||||
if (lls == 8 || lls == 9 || lls == 16 || lls == 17)
|
||||
{
|
||||
printw ("RAN [%2d] ", call_matrix[j][1]);
|
||||
}
|
||||
if (lls == 0 || lls == 1 || lls == 11 || lls == 13) //P25 P1 and DMR Voice
|
||||
{
|
||||
printw ("TID [%2d] ", call_matrix[j][1]);
|
||||
}
|
||||
|
||||
printw ("RID [%4d] ", call_matrix[j][2]);
|
||||
//printw ("S %d - ", call_matrix[j][3]);
|
||||
if (call_matrix[j][0] == 0 || call_matrix[j][0] == 1) //P25P1 Voice
|
||||
{
|
||||
printw ("NAC [0x%X] ", call_matrix[j][4]);
|
||||
}
|
||||
if (call_matrix[j][0] == 12 || call_matrix[j][0] == 13) //DMR Voice Types
|
||||
{
|
||||
printw ("DCC [%d] ", call_matrix[j][4]);
|
||||
}
|
||||
printw ("%d secs ago\n", time(NULL) - call_matrix[j][5]);
|
||||
}
|
||||
//printw("\n");
|
||||
}
|
||||
printw ("------------------------------------------------------------------------------");
|
||||
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
|
||||
//if (state->lastsynctype != -1) //is there a synctype 0?
|
||||
|
||||
|
||||
//debug sr printw
|
||||
if (1==2) //disable this later on
|
||||
{
|
||||
|
||||
printw ("sr_0 = %16llX \n", state->sr_0);
|
||||
printw ("sr_1 = %16llX \n", state->sr_1);
|
||||
printw ("sr_2 = %16llX \n", state->sr_2);
|
||||
printw ("sr_3 = %16llX \n", state->sr_3);
|
||||
printw ("sr_4 = %16llX \n", state->sr_4);
|
||||
printw ("sr_5 = %16llX \n", state->sr_5);
|
||||
printw ("sr_6 = %16llX \n", state->sr_6);
|
||||
|
||||
}
|
||||
refresh();
|
||||
|
||||
}
|
||||
|
||||
void ncursesClose ()
|
||||
|
||||
@@ -27,7 +27,7 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
||||
sum = 0;
|
||||
count = 0;
|
||||
|
||||
for (i = 0; i < state->samplesPerSymbol; i++) //right HERE, this is how many samples it will grab, depending on samplesPerSymbol and also rf_mod messing with it too
|
||||
for (i = 0; i < state->samplesPerSymbol; i++) //right HERE
|
||||
{
|
||||
|
||||
// timing control
|
||||
|
||||
107
src/nxdn_data.c
107
src/nxdn_data.c
@@ -1,36 +1,105 @@
|
||||
#include "dsd.h"
|
||||
#include "nxdn_const.h"
|
||||
|
||||
void
|
||||
processNXDNData (dsd_opts * opts, dsd_state * state)
|
||||
//don't know why this doesn't work right in LEH, need to figure that out for him
|
||||
//works just fien when ripped from his and into mine
|
||||
//must be some random thing, I'll look at his when I have a chance
|
||||
void processNXDNData (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
int i, dibit;
|
||||
int i, dibit = 0;
|
||||
unsigned char sacch_raw[72] = {0};
|
||||
unsigned char sacch_decoded[32] = {0}; /* 26 bit + 6 bit CRC */
|
||||
unsigned char *pr;
|
||||
uint8_t CrcIsGood = 0;
|
||||
uint8_t StructureField = 0;
|
||||
uint8_t RAN = 0;
|
||||
uint8_t PartOfFrame = 0;
|
||||
|
||||
/* Remove compiler warning */
|
||||
//UNUSED_VARIABLE(dibit);
|
||||
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr, "DATA ");
|
||||
}
|
||||
{
|
||||
fprintf(stderr, "DATA - ");
|
||||
}
|
||||
|
||||
/* Start pseudo-random NXDN sequence after
|
||||
* LITCH = 16 bit = 8 dibit
|
||||
* ==> Index 8 */
|
||||
pr = (unsigned char *)(&nxdnpr2[8]);
|
||||
for (i = 0; i < 30; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
|
||||
/* Store and de-interleave directly SACCH bits */
|
||||
sacch_raw[(2*i)] = ((*pr) & 1) ^ (1 & (dibit >> 1)); // bit 1
|
||||
sacch_raw[(2*i)+1] = (1 & dibit); // bit 0
|
||||
pr++;
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr, "%c", dibit + 48);
|
||||
fprintf(stderr, "%c", dibit + 48);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr, " ");
|
||||
fprintf(stderr, " ");
|
||||
#endif
|
||||
|
||||
|
||||
/* Decode the SACCH fields */
|
||||
CrcIsGood = NXDN_SACCH_raw_part_decode(sacch_raw, sacch_decoded);
|
||||
StructureField = (sacch_decoded[0]<<1 | sacch_decoded[1]<<0) & 0x03; /* Compute the Structure Field (remove 2 first bits of the SR Information in the SACCH) */
|
||||
RAN = (sacch_decoded[2]<<5 | sacch_decoded[3]<<4 | sacch_decoded[4]<<3 | sacch_decoded[5]<<2 | sacch_decoded[6]<<1 | sacch_decoded[7]<<0) & 0x3F; /* Compute the RAN (6 last bits of the SR Information in the SACCH) */
|
||||
|
||||
/* Compute the Part of Frame according to the structure field */
|
||||
if (StructureField == 3) PartOfFrame = 0;
|
||||
else if(StructureField == 2) PartOfFrame = 1;
|
||||
else if(StructureField == 1) PartOfFrame = 2;
|
||||
else if(StructureField == 0) PartOfFrame = 3;
|
||||
else PartOfFrame = 0; /* Normally we should never go here */
|
||||
|
||||
/* Fill the SACCH structure */
|
||||
state->NxdnSacchRawPart[PartOfFrame].CrcIsGood = CrcIsGood;
|
||||
state->NxdnSacchRawPart[PartOfFrame].StructureField = StructureField;
|
||||
state->NxdnSacchRawPart[PartOfFrame].RAN = RAN;
|
||||
|
||||
memcpy(state->NxdnSacchRawPart[PartOfFrame].Data, &sacch_decoded[8], 18); /* Copy the 18 bits of SACCH content */
|
||||
|
||||
//fprintf(stderr, "RAN=%02d - Part %d/4 ", RAN, PartOfFrame + 1);
|
||||
if(CrcIsGood)
|
||||
{
|
||||
fprintf (stderr, "RAN=%02d - Part %d/4 ", RAN, PartOfFrame + 1);
|
||||
fprintf (stderr, " (OK) - ");
|
||||
state->nxdn_last_ran = RAN; //disable, try to grab this in voice instead
|
||||
}
|
||||
|
||||
else fprintf (stderr, "(CRC ERR) - ");
|
||||
|
||||
|
||||
/* Decode the SACCH only when all 4 voice frame
|
||||
* SACCH spare parts have been received */
|
||||
if(PartOfFrame == 3)
|
||||
{
|
||||
/* Decode the entire SACCH content */
|
||||
NXDN_SACCH_Full_decode(opts, state);
|
||||
}
|
||||
|
||||
for (i = 0; i < 144; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr, "%c", dibit + 48);
|
||||
fprintf(stderr, "%c", dibit + 48);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
}
|
||||
{
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
/* Reset the SACCH CRCs when all 4 voice frame
|
||||
* SACCH spare parts have been received */
|
||||
if(PartOfFrame == 3)
|
||||
{
|
||||
/* Reset all CRCs of the SACCH */
|
||||
for(i = 0; i < 4; i++) state->NxdnSacchRawPart[i].CrcIsGood = 0;
|
||||
}
|
||||
} /* End processNXDNData() */
|
||||
|
||||
41
src/nxdn_data.c.bkp
Normal file
41
src/nxdn_data.c.bkp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "dsd.h"
|
||||
#include "nxdn_const.h"//going to test pushing data frames through, but not throught he processMBE portion, want to get those get frames
|
||||
|
||||
void
|
||||
processNXDNData (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
int i, dibit;
|
||||
//dibit = getDibit (opts, state);
|
||||
//fprintf (stderr, "D %c \n", dibit + 48); //adding to see what dumps exactly
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr, "DATA ");
|
||||
//dibit = getDibit (opts, state);
|
||||
//fprintf (stderr, "DE %c \n", dibit + 48); //adding to see what dumps exactly
|
||||
}
|
||||
|
||||
for (i = 0; i < 30; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr, "%c", dibit + 48);
|
||||
#endif
|
||||
}
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr, " ");
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 144; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
//fprintf (stderr, "%c", dibit + 48);
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr, "%c", dibit + 48);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
}
|
||||
72
src/nxdn_data.c.bkp2
Normal file
72
src/nxdn_data.c.bkp2
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "dsd.h"
|
||||
#include "nxdn_const.h" //test making this just like voice, but not processing MBEframes
|
||||
|
||||
void
|
||||
processNXDNData (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
int i, j, dibit, k, l;
|
||||
char ambe_fr2[4][24];
|
||||
const int *w, *x, *y, *z;
|
||||
const char *pr;
|
||||
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr,"DATA e:");
|
||||
}
|
||||
|
||||
for (i = 0; i < 30; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr,"%c", dibit + 48);
|
||||
#endif
|
||||
}
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr," ");
|
||||
#endif
|
||||
|
||||
pr = nxdnpr;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
w = nW;
|
||||
x = nX;
|
||||
y = nY;
|
||||
z = nZ;
|
||||
for (i = 0; i < 36; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
//fprintf (stderr,"%c", dibit + 48); //remove later
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr,"%c", dibit + 48);
|
||||
#endif
|
||||
ambe_fr2[*w][*x] = *pr ^ (1 & (dibit >> 1)); // bit 1
|
||||
pr++;
|
||||
ambe_fr2[*y][*z] = (1 & dibit); // bit 0
|
||||
w++;
|
||||
x++;
|
||||
y++;
|
||||
z++;
|
||||
//dump this whole lot, figure out what it all means
|
||||
//fprintf (stderr, "%s\n%s\n", ambe_fr, pr);
|
||||
}
|
||||
for (k = 0; k < 36; k++) //was 36
|
||||
{
|
||||
for (l = 0; l < 36; l++) //was 36
|
||||
{
|
||||
//fprintf (stderr, "%X%X", ambe_fr[k][l]);
|
||||
//fprintf (stderr, "%X", ambe_fr2[k][l]);
|
||||
}
|
||||
//fprintf (stderr, "\n");
|
||||
}
|
||||
//processMbeFrame (opts, state, NULL, ambe_fr, NULL);
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr," ");
|
||||
#endif
|
||||
|
||||
}
|
||||
//fprintf (stderr, "\nD%s\n%s\n", ambe_fr, pr);
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr,"\n");
|
||||
}
|
||||
}
|
||||
1084
src/nxdn_lib.c
Normal file
1084
src/nxdn_lib.c
Normal file
File diff suppressed because it is too large
Load Diff
202
src/nxdn_voice.c
202
src/nxdn_voice.c
@@ -1,59 +1,181 @@
|
||||
#include "dsd.h"
|
||||
#include "nxdn_const.h"
|
||||
|
||||
void
|
||||
processNXDNVoice (dsd_opts * opts, dsd_state * state)
|
||||
//don't know why this doesn't work right in LEH, need to figure that out for him
|
||||
//works just fien when ripped from his and into mine
|
||||
//must be some random thing, I'll look at his when I have a chance
|
||||
void processNXDNVoice (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
int i, j, dibit;
|
||||
char ambe_fr[4][24];
|
||||
unsigned char sacch_raw[72] = {0};
|
||||
unsigned char sacch_decoded[32] = {0}; /* 26 bit + 6 bit CRC */
|
||||
const int *w, *x, *y, *z;
|
||||
const char *pr;
|
||||
unsigned char *pr;
|
||||
uint8_t CrcIsGood = 0;
|
||||
uint8_t StructureField = 0;
|
||||
uint8_t RAN = 0;
|
||||
uint8_t PartOfFrame = 0;
|
||||
uint8_t KeyStream[1664] = {0};
|
||||
char ambe7bytesArray[7] = {0};
|
||||
int PartOfEncryptedSuperFrame = 0;
|
||||
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr,"VOICE e:");
|
||||
}
|
||||
{
|
||||
fprintf(stderr, "VOICE - ");
|
||||
}
|
||||
|
||||
/* Start pseudo-random NXDN sequence after
|
||||
* LITCH = 16 bit = 8 dibit
|
||||
* ==> Index 8 */
|
||||
pr = (unsigned char *)(&nxdnpr2[8]);
|
||||
for (i = 0; i < 30; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
|
||||
/* Store and de-interleave directly SACCH bits */
|
||||
sacch_raw[(2*i)] = ((*pr) & 1) ^ (1 & (dibit >> 1)); // bit 1
|
||||
sacch_raw[(2*i)+1] = (1 & dibit); // bit 0
|
||||
|
||||
// TODO : Deinterleave is done in the "NXDN_SACCH_decode" function
|
||||
// /* Store and de-interleave directly SACCH bits */
|
||||
// sacch_raw[nsW[2*i]] = *pr ^ (1 & (dibit >> 1)); // bit 1
|
||||
// sacch_raw[nsW[2*i+1]] = (1 & dibit); // bit 0
|
||||
pr++;
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf(stderr, "%c", dibit + 48);
|
||||
#endif
|
||||
}
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf(stderr, " ");
|
||||
#endif
|
||||
|
||||
// TODO : Unpuncture is done in the "NXDN_SACCH_decode" function
|
||||
// /* For the sake of simplicity, handle the re-insertion of punctured bits here.
|
||||
// * This makes the actual Viterbi decoder code a LOT simpler. */
|
||||
// for (i = 30; i < 36; i++)
|
||||
// {
|
||||
// sacch_raw[nsW[2*i]] = 0;
|
||||
// sacch_raw[nsW[2*i+1]] = 0;
|
||||
// }
|
||||
|
||||
/* Decode the SACCH fields */
|
||||
CrcIsGood = NXDN_SACCH_raw_part_decode(sacch_raw, sacch_decoded);
|
||||
StructureField = (sacch_decoded[0]<<1 | sacch_decoded[1]<<0) & 0x03; /* Compute the Structure Field (remove 2 first bits of the SR Information in the SACCH) */
|
||||
RAN = (sacch_decoded[2]<<5 | sacch_decoded[3]<<4 | sacch_decoded[4]<<3 | sacch_decoded[5]<<2 | sacch_decoded[6]<<1 | sacch_decoded[7]<<0) & 0x3F; /* Compute the RAN (6 last bits of the SR Information in the SACCH) */
|
||||
|
||||
/* Compute the Part of Frame according to the structure field */
|
||||
if (StructureField == 3) PartOfFrame = 0;
|
||||
else if(StructureField == 2) PartOfFrame = 1;
|
||||
else if(StructureField == 1) PartOfFrame = 2;
|
||||
else if(StructureField == 0) PartOfFrame = 3;
|
||||
else PartOfFrame = 0; /* Normally we should never go here */
|
||||
|
||||
/* Fill the SACCH structure */
|
||||
state->NxdnSacchRawPart[PartOfFrame].CrcIsGood = CrcIsGood;
|
||||
state->NxdnSacchRawPart[PartOfFrame].StructureField = StructureField;
|
||||
state->NxdnSacchRawPart[PartOfFrame].RAN = RAN;
|
||||
memcpy(state->NxdnSacchRawPart[PartOfFrame].Data, &sacch_decoded[8], 18); /* Copy the 18 bits of SACCH content */
|
||||
|
||||
//fprintf(stderr, "RAN=%02d - Part %d/4 ", RAN, PartOfFrame + 1);
|
||||
//if(CrcIsGood) fprintf(stderr, " (OK) - ");
|
||||
if(CrcIsGood)
|
||||
{
|
||||
fprintf (stderr, "RAN=%02d - Part %d/4 ", RAN, PartOfFrame + 1);
|
||||
fprintf (stderr, " (OK) - ");
|
||||
state->nxdn_last_ran = RAN; //disable, try to grab this in voice instead
|
||||
}
|
||||
else fprintf(stderr, "(CRC ERR) - ");
|
||||
|
||||
/* Generate the key stream */
|
||||
NxdnEncryptionStreamGeneration(opts, state, KeyStream);
|
||||
|
||||
//fprintf(stderr, "\nKeyStream = ");
|
||||
//for(i = 0; i < 49; i++) fprintf(stderr, "%d", KeyStream[i]);
|
||||
//fprintf(stderr, "\n");
|
||||
|
||||
|
||||
/* Determine the current part of superframe
|
||||
* (in an AES or DES encrypted frame, two superframes
|
||||
* are used with the same IV, so to decipher the sound
|
||||
* correctly we must know the current superframe part) */
|
||||
if(state->NxdnElementsContent.PartOfNextEncryptedFrame == 1) PartOfEncryptedSuperFrame = 0;
|
||||
else if(state->NxdnElementsContent.PartOfNextEncryptedFrame == 2) PartOfEncryptedSuperFrame = 1;
|
||||
else PartOfEncryptedSuperFrame = 0;
|
||||
|
||||
/* Decode the SACCH only when all 4 voice frame
|
||||
* SACCH spare parts have been received */
|
||||
if(PartOfFrame == 3)
|
||||
{
|
||||
/* Decode the entire SACCH content */
|
||||
NXDN_SACCH_Full_decode(opts, state);
|
||||
}
|
||||
|
||||
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf(stderr, "e:");
|
||||
}
|
||||
|
||||
/* Start pseudo-random NXDN sequence after
|
||||
* LITCH = 16 bit = 8 dibit +
|
||||
* SACCH = 60 bit = 30 dibit
|
||||
* = 76 bit = 38 dibit
|
||||
* ==> Index 38 */
|
||||
pr = (unsigned char *)(&nxdnpr2[38]);
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
w = nW;
|
||||
x = nX;
|
||||
y = nY;
|
||||
z = nZ;
|
||||
for (i = 0; i < 36; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr,"%c", dibit + 48);
|
||||
#endif
|
||||
}
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr," ");
|
||||
fprintf(stderr, "%c", dibit + 48);
|
||||
#endif
|
||||
ambe_fr[*w][*x] = *pr ^ (1 & (dibit >> 1)); // bit 1
|
||||
pr++;
|
||||
ambe_fr[*y][*z] = (1 & dibit); // bit 0
|
||||
|
||||
pr = nxdnpr;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
w = nW;
|
||||
x = nX;
|
||||
y = nY;
|
||||
z = nZ;
|
||||
for (i = 0; i < 36; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr,"%c", dibit + 48);
|
||||
#endif
|
||||
ambe_fr[*w][*x] = *pr ^ (1 & (dibit >> 1)); // bit 1
|
||||
pr++;
|
||||
ambe_fr[*y][*z] = (1 & dibit); // bit 0
|
||||
w++;
|
||||
x++;
|
||||
y++;
|
||||
z++;
|
||||
}
|
||||
processMbeFrame (opts, state, NULL, ambe_fr, NULL);
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr," ");
|
||||
#endif
|
||||
w++;
|
||||
x++;
|
||||
y++;
|
||||
z++;
|
||||
}
|
||||
//processMbeFrame (opts, state, NULL, ambe_fr, NULL);
|
||||
processMbeFrameEncrypted(opts, state, NULL, ambe_fr, NULL, (char *)&KeyStream[(PartOfEncryptedSuperFrame * 4 * 4 * 49) + (PartOfFrame * 4 * 49) + (j * 49)], NULL);
|
||||
|
||||
|
||||
#ifdef BUILD_DSD_WITH_FRAME_CONTENT_DISPLAY
|
||||
if(state->printNXDNAmbeVoiceSampleHex)
|
||||
{
|
||||
/* Display AMBE frame content */
|
||||
/* Convert the 49 bit AMBE frame into 7 bytes */
|
||||
Convert49BitSampleInto7Bytes(state->ambe_deciphered, ambe7bytesArray);
|
||||
fprintf(stderr, "\nVoice Frame %d/4 : ", j + 1);
|
||||
fprintf(stderr, "E1 = %d ; E2 = %d ; Content = ", state->errs, state->errs2);
|
||||
for(i = 0; i < 7; i++) fprintf(stderr, "0x%02X, ", ambe7bytesArray[i] & 0xFF);
|
||||
//fprintf(stderr, "\n");
|
||||
}
|
||||
#endif /* BUILD_DSD_WITH_FRAME_CONTENT_DISPLAY */
|
||||
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf(stderr, " ");
|
||||
#endif
|
||||
} /* End for (j = 0; j < 4; j++) */
|
||||
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr,"\n");
|
||||
}
|
||||
}
|
||||
{
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
/* Reset the SACCH CRCs when all 4 voice frame
|
||||
* SACCH spare parts have been received */
|
||||
if(PartOfFrame == 3)
|
||||
{
|
||||
/* Reset all CRCs of the SACCH */
|
||||
for(i = 0; i < 4; i++) state->NxdnSacchRawPart[i].CrcIsGood = 0;
|
||||
}
|
||||
} /* End processNXDNVoice() */
|
||||
|
||||
118
src/nxdn_voice.c.bkp3
Normal file
118
src/nxdn_voice.c.bkp3
Normal file
@@ -0,0 +1,118 @@
|
||||
#include "dsd.h"
|
||||
#include "nxdn_const.h"
|
||||
|
||||
void
|
||||
processNXDNVoice (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
int i, j, dibit, k, l;
|
||||
char ambe_fr[4][24];
|
||||
const int *w, *x, *y, *z;
|
||||
const char *pr;
|
||||
//borrow from LEH data
|
||||
unsigned char sacch_raw[72] = {0};
|
||||
unsigned char sacch_decoded[32] = {0}; /* 26 bit + 6 bit CRC */
|
||||
unsigned char *pr2; //change this to pr2 to differentiate
|
||||
uint8_t CrcIsGood = 0;
|
||||
uint8_t StructureField = 0;
|
||||
uint8_t RAN = 0;
|
||||
uint8_t PartOfFrame = 0;
|
||||
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr,"VOICE e:");
|
||||
}
|
||||
|
||||
for (i = 0; i < 30; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr,"%c", dibit + 48);
|
||||
#endif
|
||||
}
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr," ");
|
||||
#endif
|
||||
|
||||
pr = nxdnpr;
|
||||
pr2 = (unsigned char *)(&nxdnpr2[8]); //from LEH data
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
w = nW;
|
||||
x = nX;
|
||||
y = nY;
|
||||
z = nZ;
|
||||
for (i = 0; i < 36; i++)
|
||||
{
|
||||
dibit = getDibit (opts, state);
|
||||
//fprintf (stderr,"%c", dibit + 48); //remove later
|
||||
if (i < 30){
|
||||
sacch_raw[(2*i)] = ((*pr2) & 1) ^ (1 & (dibit >> 1)); // bit 1
|
||||
sacch_raw[(2*i)+1] = (1 & dibit); // bit 0
|
||||
}
|
||||
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr,"%c", dibit + 48);
|
||||
#endif
|
||||
ambe_fr[*w][*x] = *pr ^ (1 & (dibit >> 1)); // bit 1
|
||||
pr++;
|
||||
ambe_fr[*y][*z] = (1 & dibit); // bit 0
|
||||
w++;
|
||||
x++;
|
||||
y++;
|
||||
z++;
|
||||
}
|
||||
processMbeFrame (opts, state, NULL, ambe_fr, NULL);
|
||||
//from LEH data
|
||||
/* Decode the SACCH fields */
|
||||
CrcIsGood = NXDN_SACCH_raw_part_decode(sacch_raw, sacch_decoded);
|
||||
StructureField = (sacch_decoded[0]<<1 | sacch_decoded[1]<<0) & 0x03; /* Compute the Structure Field (remove 2 first bits of the SR Information in the SACCH) */
|
||||
RAN = (sacch_decoded[2]<<5 | sacch_decoded[3]<<4 | sacch_decoded[4]<<3 | sacch_decoded[5]<<2 | sacch_decoded[6]<<1 | sacch_decoded[7]<<0) & 0x3F; /* Compute the RAN (6 last bits of the SR Information in the SACCH) */
|
||||
|
||||
/* Compute the Part of Frame according to the structure field */
|
||||
if (StructureField == 3) PartOfFrame = 0;
|
||||
else if(StructureField == 2) PartOfFrame = 1;
|
||||
else if(StructureField == 1) PartOfFrame = 2;
|
||||
else if(StructureField == 0) PartOfFrame = 3;
|
||||
else PartOfFrame = 0; /* Normally we should never go here */
|
||||
|
||||
/* Fill the SACCH structure */
|
||||
state->NxdnSacchRawPart[PartOfFrame].CrcIsGood = CrcIsGood;
|
||||
state->NxdnSacchRawPart[PartOfFrame].StructureField = StructureField;
|
||||
state->NxdnSacchRawPart[PartOfFrame].RAN = RAN;
|
||||
|
||||
memcpy(state->NxdnSacchRawPart[PartOfFrame].Data, &sacch_decoded[8], 18); /* Copy the 18 bits of SACCH content */
|
||||
|
||||
//fprintf(stderr, "RAN=%02d - Part %d/4 ", RAN, PartOfFrame + 1);
|
||||
if(CrcIsGood)
|
||||
{
|
||||
//fprintf (stderr, "RAN=%02d - Part %d/4 ", RAN, PartOfFrame + 1);
|
||||
//fprintf (stderr, " (OK) - ");
|
||||
state->nxdn_last_ran = RAN; //disable, try to grab this in voice instead
|
||||
}
|
||||
|
||||
else fprintf (stderr, "(CRC ERR) - ");
|
||||
|
||||
if(PartOfFrame == 3)
|
||||
{
|
||||
/* Decode the entire SACCH content */
|
||||
NXDN_SACCH_Full_decode(opts, state);
|
||||
}
|
||||
|
||||
/* Reset the SACCH CRCs when all 4 voice frame
|
||||
* SACCH spare parts have been received */
|
||||
if(PartOfFrame == 3)
|
||||
{
|
||||
/* Reset all CRCs of the SACCH */
|
||||
for(i = 0; i < 4; i++) state->NxdnSacchRawPart[i].CrcIsGood = 0;
|
||||
}
|
||||
#ifdef NXDN_DUMP
|
||||
fprintf (stderr," ");
|
||||
#endif
|
||||
}
|
||||
//fprintf (stderr, "\nV%c\n%c\n", ambe_fr, pr);
|
||||
if (opts->errorbars == 1)
|
||||
{
|
||||
fprintf (stderr,"\n");
|
||||
}
|
||||
}
|
||||
171
src/nxdnconvolution.c
Normal file
171
src/nxdnconvolution.c
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2016,2018 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* Copyright (C) 2018 by Edouard Griffiths F4EXB:
|
||||
* - Cosmetic changes to integrate with DSDcc
|
||||
*
|
||||
* Copyright (C) 2018 by Louis HERVE F4HUZ:
|
||||
* - Transform C++ lib into C lib to integrate with DSD
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
/* Include ------------------------------------------------------------------*/
|
||||
//#include "nxdnconvolution.h"
|
||||
|
||||
#include <stdio.h>
|
||||
//#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/* Define -------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Global variables ---------------------------------------------------------*/
|
||||
static const uint8_t CNXDNConvolution_BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U};
|
||||
|
||||
#define WRITE_BIT1(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | CNXDNConvolution_BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~CNXDNConvolution_BIT_MASK_TABLE[(i)&7])
|
||||
#define READ_BIT1(p,i) (p[(i)>>3] & CNXDNConvolution_BIT_MASK_TABLE[(i)&7])
|
||||
|
||||
static const uint8_t CNXDNConvolution_BRANCH_TABLE1[] = {0U, 0U, 0U, 0U, 2U, 2U, 2U, 2U};
|
||||
static const uint8_t CNXDNConvolution_BRANCH_TABLE2[] = {0U, 2U, 2U, 0U, 0U, 2U, 2U, 0U};
|
||||
|
||||
static const unsigned int CNXDNConvolution_NUM_OF_STATES_D2 = 8U;
|
||||
static const unsigned int CNXDNConvolution_NUM_OF_STATES = 16U;
|
||||
static const uint32_t CNXDNConvolution_M = 4U;
|
||||
static const unsigned int CNXDNConvolution_K = 5U;
|
||||
|
||||
static uint16_t m_metrics1[16U] = {0};
|
||||
static uint16_t m_metrics2[16U] = {0};
|
||||
static uint64_t m_decisions[300U] = {0};
|
||||
static uint16_t * m_oldMetrics = NULL;
|
||||
static uint16_t * m_newMetrics = NULL;
|
||||
static uint64_t * m_dp = NULL;
|
||||
|
||||
|
||||
/* Functions ----------------------------------------------------------------*/
|
||||
|
||||
void CNXDNConvolution_start(void)
|
||||
{
|
||||
memset(m_metrics1, 0x00U, CNXDNConvolution_NUM_OF_STATES * sizeof(uint16_t));
|
||||
memset(m_metrics2, 0x00U, CNXDNConvolution_NUM_OF_STATES * sizeof(uint16_t));
|
||||
|
||||
m_oldMetrics = m_metrics1;
|
||||
m_newMetrics = m_metrics2;
|
||||
m_dp = m_decisions;
|
||||
}
|
||||
|
||||
|
||||
void CNXDNConvolution_decode(uint8_t s0, uint8_t s1)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
uint8_t j = 0;
|
||||
uint8_t decision0 = 0;
|
||||
uint8_t decision1 = 0;
|
||||
uint16_t metric = 0;
|
||||
uint16_t m0 = 0;
|
||||
uint16_t m1 = 0;
|
||||
uint16_t * tmp = NULL;
|
||||
|
||||
*m_dp = 0U;
|
||||
|
||||
for (i = 0U; i < CNXDNConvolution_NUM_OF_STATES_D2; i++)
|
||||
{
|
||||
j = i * 2U;
|
||||
|
||||
metric = abs(CNXDNConvolution_BRANCH_TABLE1[i] - s0) + abs(CNXDNConvolution_BRANCH_TABLE2[i] - s1);
|
||||
|
||||
m0 = m_oldMetrics[i] + metric;
|
||||
m1 = m_oldMetrics[i + CNXDNConvolution_NUM_OF_STATES_D2] + (CNXDNConvolution_M - metric);
|
||||
decision0 = (m0 >= m1) ? 1U : 0U;
|
||||
m_newMetrics[j + 0U] = decision0 != 0U ? m1 : m0;
|
||||
|
||||
m0 = m_oldMetrics[i] + (CNXDNConvolution_M - metric);
|
||||
m1 = m_oldMetrics[i + CNXDNConvolution_NUM_OF_STATES_D2] + metric;
|
||||
decision1 = (m0 >= m1) ? 1U : 0U;
|
||||
m_newMetrics[j + 1U] = decision1 != 0U ? m1 : m0;
|
||||
|
||||
*m_dp |= ((uint64_t)(decision1) << (j + 1U)) | ((uint64_t)(decision0) << (j + 0U));
|
||||
}
|
||||
|
||||
++m_dp;
|
||||
|
||||
//assert((m_dp - m_decisions) <= 300);
|
||||
|
||||
tmp = m_oldMetrics;
|
||||
m_oldMetrics = m_newMetrics;
|
||||
m_newMetrics = tmp;
|
||||
}
|
||||
|
||||
void CNXDNConvolution_chainback(unsigned char* out, unsigned int nBits)
|
||||
{
|
||||
//assert(out != 0);
|
||||
|
||||
uint32_t state = 0U;
|
||||
uint32_t i = 0;
|
||||
uint8_t bit = 0;
|
||||
|
||||
while (nBits-- > 0)
|
||||
{
|
||||
--m_dp;
|
||||
|
||||
i = state >> (9 - CNXDNConvolution_K);
|
||||
bit = (uint8_t)(*m_dp >> i) & 1;
|
||||
state = (bit << 7) | (state >> 1);
|
||||
|
||||
WRITE_BIT1(out, nBits, bit != 0U);
|
||||
}
|
||||
}
|
||||
|
||||
void CNXDNConvolution_encode(const unsigned char* in, unsigned char* out, unsigned int nBits)
|
||||
{
|
||||
//assert(in != 0);
|
||||
//assert(out != 0);
|
||||
//assert(nBits > 0U);
|
||||
|
||||
uint8_t g1 = 0U;
|
||||
uint8_t g2 = 0U;
|
||||
uint8_t d = 0U;
|
||||
uint8_t d1 = 0U;
|
||||
uint8_t d2 = 0U;
|
||||
uint8_t d3 = 0U;
|
||||
uint8_t d4 = 0U;
|
||||
uint32_t k = 0U;
|
||||
unsigned int i = 0U;
|
||||
|
||||
for (i = 0U; i < nBits; i++)
|
||||
{
|
||||
d = READ_BIT1(in, i) ? 1U : 0U;
|
||||
|
||||
g1 = (d + d3 + d4) & 1;
|
||||
g2 = (d + d1 + d2 + d4) & 1;
|
||||
|
||||
d4 = d3;
|
||||
d3 = d2;
|
||||
d2 = d1;
|
||||
d1 = d;
|
||||
|
||||
WRITE_BIT1(out, k, g1 != 0U);
|
||||
k++;
|
||||
|
||||
WRITE_BIT1(out, k, g2 != 0U);
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user