* Changes to insure that array boundaries are not exceeded
  * Moved large array from stack to static store.
  * Added cmd line parameter --debug-audio to enable audio
    debug events.  default is off.
pull/1/head
David Freese 2013-07-04 09:33:57 -05:00
rodzic 07f9cb8e5f
commit e624bc0bec
8 zmienionych plików z 86 dodań i 41 usunięć

Wyświetl plik

@ -87,6 +87,7 @@ unused__ static uint32_t log_source_ = debug::LOG_OTHER;
#define LOG_SET_SOURCE(source__) log_source_ = source__
extern bool debug_pskmail;
extern bool debug_audio;
#endif // _DEBUG_H_

Wyświetl plik

@ -62,6 +62,10 @@
#define THORSLOWPATHS 3
#define THORFASTPATHS 5
// the following constant changes if a mode with more tones than 25x4 is
// created
#define MAXPATHS (8 * THORFASTPATHS * THORNUMTONES )
struct THORrxpipe {
complex vector[THORMAXFFTS * THORNUMTONES * 6];
};

Wyświetl plik

@ -672,6 +672,9 @@ void generate_option_help(void) {
<< " --debug-pskmail\n"
<< " Enable logging for pskmail / arq events\n\n"
<< " --debug-audio\n"
<< " Enable logging for sound-card events\n\n"
<< " --version\n"
<< " Print version information\n\n"
@ -771,7 +774,7 @@ int parse_args(int argc, char **argv, int& idx)
#if USE_PORTAUDIO
OPT_FRAMES_PER_BUFFER,
#endif
OPT_NOISE, OPT_DEBUG_LEVEL, OPT_DEBUG_PSKMAIL,
OPT_NOISE, OPT_DEBUG_LEVEL, OPT_DEBUG_PSKMAIL, OPT_DEBUG_AUDIO,
OPT_EXIT_AFTER,
OPT_DEPRECATED, OPT_HELP, OPT_VERSION, OPT_BUILD_INFO };
@ -825,6 +828,7 @@ int parse_args(int argc, char **argv, int& idx)
{ "noise", 0, 0, OPT_NOISE },
{ "debug-level", 1, 0, OPT_DEBUG_LEVEL },
{ "debug-pskmail", 0, 0, OPT_DEBUG_PSKMAIL },
{ "debug-audio", 0, 0, OPT_DEBUG_AUDIO },
{ "help", 0, 0, OPT_HELP },
{ "version", 0, 0, OPT_VERSION },
@ -1028,6 +1032,10 @@ int parse_args(int argc, char **argv, int& idx)
debug_pskmail = true;
break;
case OPT_DEBUG_AUDIO:
debug_audio = true;
break;
case OPT_DEPRECATED:
cerr << "W: the --" << longopts[longindex].name
<< " option has been deprecated and will be removed in a future version\n";

Wyświetl plik

@ -85,6 +85,7 @@ debug::level_e debug::level = debug::INFO_LEVEL;
uint32_t debug::mask = ~0u;
bool debug_pskmail = false;
bool debug_audio = false;
static const char* prefix[] = {
_("Quiet"), _("Error"), _("Warning"), _("Info"), _("Verbose"), _("Debug")
@ -183,7 +184,7 @@ void debug::log(level_e level, const char* func, const char* srcf, int line, con
if (!inst)
return;
if (unlikely(debug::level == DEBUG_LEVEL) || debug_pskmail) {
if (unlikely(debug::level == DEBUG_LEVEL) || debug_pskmail || debug_audio) {
time_t t = time(NULL);
struct tm stm;
(void)localtime_r(&t, &stm);

Wyświetl plik

@ -1406,8 +1406,8 @@ void SoundPort::init_stream(unsigned dir)
<< "\ndefault high output latency: " << (*sd[dir].idev)->defaultHighOutputLatency
<< "\n";
LOG_DEBUG("using %s (%d ch) device \"%s\":\n%s", dir_str[dir], sd[dir].params.channelCount,
sd[dir].device.c_str(), device_text[dir].str().c_str());
// LOG_DEBUG("using %s (%d ch) device \"%s\":\n%s", dir_str[dir], sd[dir].params.channelCount,
// sd[dir].device.c_str(), device_text[dir].str().c_str());
sd[dir].dev_sample_rate = find_srate(dir);

Wyświetl plik

@ -45,7 +45,8 @@
#include "debug.h"
// Enable to enable profiling output for the soft-decision decoder
#define SOFTPROFILE true
#define SOFTPROFILE false
//#define SOFTPROFILE true
using namespace std;
@ -85,14 +86,18 @@ void thor::rx_init()
datashreg = 1;
sig = noise = 6;
fec_confidence = 0;
s2n_valid = false;
}
void thor::reset_filters()
{
//LOG_INFO("%s", "Reset filters");
// fft filter at first IF frequency
if (fft)
fft->create_filter( (THORFIRSTIF - 0.5 * progdefaults.THOR_BW * bandwidth) / samplerate,
(THORFIRSTIF + 0.5 * progdefaults.THOR_BW * bandwidth)/ samplerate );
(THORFIRSTIF + 0.5 * progdefaults.THOR_BW * bandwidth)/ samplerate );
for (int i = 0; i < THORMAXFFTS; i++)
if (binsfft[i]) {
@ -113,9 +118,23 @@ void thor::reset_filters()
numbins = hitone - lotone;
for (int i = 0; i < paths; i++)
binsfft[i] = new sfft (symlen, lotone, hitone);
//LOG_INFO("MAX ARRAY SIZE %d, paths %d, numbins %d, array_size %d", MAXPATHS, paths, numbins, numbins * paths);
for (int i = 0; i < paths; i++) {
if (binsfft[i]) delete binsfft[i];
binsfft[i] = new sfft (symlen, lotone, hitone);
}
//LOG_INFO("binsfft(%d) initialized", paths);
for (int i = 0; i < THORSCOPESIZE; i++) {
if (vidfilter[i]) delete vidfilter[i];
vidfilter[i] = new Cmovavg(16);
}
//LOG_INFO("vidfilter(%d) initialized", THORSCOPESIZE);
if (syncfilter) delete syncfilter;
syncfilter = new Cmovavg(8);
//LOG_INFO("%s", "syncfilter initialized");
filter_reset = false;
}
@ -127,6 +146,7 @@ void thor::restart()
void thor::init()
{
//LOG_INFO("%s", "thor::init");
modem::init();
// reset_filters();
rx_init();
@ -157,7 +177,7 @@ thor::~thor()
}
thor::thor(trx_mode md)
thor::thor(trx_mode md) : hilbert(0), fft(0), filter_reset(false)
{
cap |= CAP_REV;
@ -257,14 +277,12 @@ thor::thor(trx_mode md)
for (int i = 0; i < THORMAXFFTS; i++)
binsfft[i] = 0;
for (int i = 0; i < THORSCOPESIZE; i++)
vidfilter[i] = 0;
syncfilter = 0;
reset_filters();
for (int i = 0; i < THORSCOPESIZE; i++)
vidfilter[i] = new Cmovavg(16);
syncfilter = new Cmovavg(8);
twosym = 2 * symlen;
pipe = new THORrxpipe[twosym];
@ -301,6 +319,7 @@ thor::thor(trx_mode md)
symbolpair[0] = symbolpair[1] = 0;
datashreg = 1;
init();
}
//=====================================================================
@ -392,6 +411,7 @@ void thor::decodePairs(unsigned char symbol)
if ((datashreg & 7) == 1) {
ch = thorvaridec(datashreg >> 1);
recvchar(ch);
//LOG_INFO("thorvaridec %X = %d", datashreg >> 1, ch);
datashreg = 1;
}
@ -464,7 +484,7 @@ void thor::softdecodesymbol()
}
}
#if SOFTPROFILE
LOG_DEBUG("\nSymbol: %3d; DELTAf: +%3d",currsymbol, c);
LOG_INFO("\nSymbol: %3d; DELTAf: +%3d",currsymbol, c);
#endif
}
c -= 2;
@ -511,9 +531,9 @@ void thor::softdecodesymbol()
}
#if SOFTPROFILE
LOG_DEBUG("next mag %.3d | now mag %.3d | last mag %.3d",nextmag, nowmag, lastmag);
if (outofrange) LOG_DEBUG("%s","outofrange");
if (staticburst) LOG_DEBUG("%s","staticburst");
LOG_INFO("next mag %.3d | now mag %.3d | last mag %.3d",nextmag, nowmag, lastmag);
if (outofrange) LOG_INFO("%s","outofrange");
if (staticburst) LOG_INFO("%s","staticburst");
#endif
lastsymbols[3] = (lastc & 1) == 1 ? one : zero ; lastc /= 2;
@ -536,9 +556,11 @@ int thor::harddecode()
double x, max = 0.0;
int symbol = 0;
double avg = 0.0;
bool cwi[paths * numbins];
static bool cwi[MAXPATHS]; //[paths * numbins];
double cwmag;
for (int i = 0; i < MAXPATHS; i++) cwi[i] = false;
for (int i = 0; i < paths * numbins; i++)
avg += pipe[pipeptr].vector[i].mag();
avg /= (paths * numbins);
@ -566,7 +588,8 @@ int thor::harddecode()
max = x;
symbol = i;
}
}
} else
LOG_DEBUG("cwi detected in bin %d", i);
}
staticburst = (max / avg < 1.2);
@ -576,6 +599,8 @@ int thor::harddecode()
int thor::softdecode()
{
static bool lastCWI[MAXPATHS] = {false};
static bool nextCWI[MAXPATHS] = {false};
static const int SoftBailout=6; // Max number of attempts to get a valid symbol
double x, max = 0.0, avg = 0.0;
@ -583,17 +608,17 @@ int thor::softdecode()
int avgcount = 0;
int soft_symbol_trycount=0;
static bool lastCWI[1024] = {false};
bool nextCWI[paths * numbins];
int lowest_tone = 0;
int highest_tone = paths * numbins;
// Clear nextCWI bool array for this run
for (int i = lowest_tone; i < highest_tone; i++) nextCWI[i] = false;
// Clear nextCWI bool array for this run
for (int i = 0; i < MAXPATHS; i++)
nextCWI[i] = false;
// for (int i = lowest_tone; i < highest_tone; i++) nextCWI[i] = false;
// Allow for case where symbol == prev2symbol (before calculating signal average...)
lastCWI[prev2symbol-1] = lastCWI[prev2symbol] = lastCWI[prev2symbol+1] = false;
if (prev2symbol && (prev2symbol < MAXPATHS - 1)) // array bounds checking
lastCWI[prev2symbol-1] = lastCWI[prev2symbol] = lastCWI[prev2symbol+1] = false;
// Constrict the tone set further so CWI detect & set does not go out of intended range
lowest_tone += 1;
@ -624,13 +649,15 @@ int thor::softdecode()
}
}
if (symbol && (symbol < MAXPATHS - 1)) { // array bounds checking
// detect repeated symbols (an invalid pattern for IFK+ modems)
if ( abs(prev1symbol - symbol) < paths ) {
nextCWI[symbol-1] = nextCWI[symbol] = nextCWI[symbol+1] = true;
}
if ( abs(prev1symbol - symbol) < paths ) {
nextCWI[symbol-1] = nextCWI[symbol] = nextCWI[symbol+1] = true;
}
// Update the next CWI mask if the tone from last-run persists
else if ( lastCWI[symbol-1] || lastCWI[symbol] || lastCWI[symbol+1] ) {
nextCWI[symbol-1] = nextCWI[symbol] = nextCWI[symbol+1] = true;
else if ( lastCWI[symbol-1] || lastCWI[symbol] || lastCWI[symbol+1] ) {
nextCWI[symbol-1] = nextCWI[symbol] = nextCWI[symbol+1] = true;
}
}
} while ( nextCWI[symbol] && soft_symbol_trycount < SoftBailout ); // Run while the detected symbol has been identified as CWI (alt: bailout after 6 trys)
@ -660,9 +687,9 @@ bool thor::preambledetect(int c)
// -16 does not reset the twos counter
if (-16 != c && 2 != c)
if (twocount > 1) twocount -= 2;
//#if SOFTPROFILE
// LOG_DEBUG("[2count:pcheck] [%d:%d]",twocount, preamblecheck);
//#endif
#if SOFTPROFILE
LOG_INFO("[2count:pcheck] [%d:%d]",twocount, preamblecheck);
#endif
if ( twocount > 4 && neg16seen ){
if ( ++preamblecheck > 4 ) return true;
}
@ -674,6 +701,9 @@ bool thor::preambledetect(int c)
// Flush the interleaver and convolutional decoder with punctures
void thor::softflushrx()
{
#if SOFTPROFILE
LOG_INFO("%s", "softflushrx()");
#endif
unsigned char puncture[2], flushsymbols[4];
puncture[0]=128;
puncture[1]=128;
@ -692,7 +722,7 @@ void thor::update_syncscope()
double max = 0, min = 1e6, range, mag;
memset(videodata, 0, paths * numbins * sizeof(double));
//LOG_INFO("%s", "cleared videodata");
if (!progStatus.sqlonoff || metric >= progStatus.sldrSquelchValue) {
for (int i = 0; i < paths * numbins; i++ ) {
mag = pipe[pipeptr].vector[i].mag();
@ -803,20 +833,20 @@ int thor::rx_process(const double *buf, int len)
complex zarray[1];
int n;
if (filter_reset) reset_filters();
if (slowcpu != progdefaults.slowcpu) {
slowcpu = progdefaults.slowcpu;
reset_filters();
filter_reset = true;
}
if (filter_reset) reset_filters();
while (len) {
// create analytic signal at first IF
zref.re = zref.im = *buf++;
hilbert->run(zref, zref);
zref = mixer(0, zref);
if (progdefaults.THOR_FILTER) {
if (progdefaults.THOR_FILTER && fft) {
// filter using fft convolution
n = fft->run(zref, &zp);
} else {

Wyświetl plik

@ -165,6 +165,7 @@ static const unsigned int thor_varidecode[] = {
0xF68, 0xF6C, 0xF70, 0xF74, 0xF78, 0xF7C, 0xF80, 0xFA0,
0xFA8, 0xFAC, 0xFB0
};
static int limit = sizeof(thor_varidecode)/sizeof(unsigned int);
const char *thorvarienc(int c, int sec)
{
@ -184,7 +185,7 @@ int thorvaridec(unsigned int symbol)
if (symbol < 0xB80)
return varidec(symbol); // find in the MFSK decode table
for (i = 0; i < 92; i++)
for (i = 0; i < limit; i++)
if (symbol == thor_varidecode[i])
return (' ' + i + 0x100); // found in the extended decode table

Wyświetl plik

@ -987,7 +987,7 @@ void FTextTX::add_text(string s)
redraw();
}
} else {
LOG_DEBUG("%04x ", s[n] & 0x00FF);
//LOG_DEBUG("%04x ", s[n] & 0x00FF);
add(s[n] & 0xFF, RECV);
}
}