From 0ce5de0f28af04935e939f53799a8d122e2ca9bb Mon Sep 17 00:00:00 2001 From: Steven Franke Date: Mon, 12 Feb 2018 01:13:03 +0000 Subject: [PATCH] Another round of tweaks to wsprd. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8500 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/wsprd/wsprd.c | 2 +- lib/wsprd/wsprsim_utils.c | 60 +++++++++++++++++++-------------------- lib/wsprd/wsprsim_utils.h | 12 -------- 3 files changed, 30 insertions(+), 44 deletions(-) diff --git a/lib/wsprd/wsprd.c b/lib/wsprd/wsprd.c index 21c0cb043..e2741f3f8 100644 --- a/lib/wsprd/wsprd.c +++ b/lib/wsprd/wsprd.c @@ -144,7 +144,7 @@ unsigned long readwavfile(char *ptr_to_infile, int ntrmin, float *idat, float *q fclose(fp); realin=(float*) fftwf_malloc(sizeof(float)*nfft1); - fftout=(fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex)*nfft1); + fftout=(fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex)*(nfft1/2+1)); PLAN1 = fftwf_plan_dft_r2c_1d(nfft1, realin, fftout, PATIENCE); for (i=0; i=48 && ch <=57 ) { //0-9 return ch-48; @@ -32,7 +39,7 @@ char get_callsign_character_code(char ch) { return -1; } -long unsigned int pack_grid4_power(char *grid4, int power) { +long unsigned int pack_grid4_power(char const *grid4, int power) { long unsigned int m; m=(179-10*grid4[0]-grid4[2])*180+10*grid4[1]+grid4[3]; @@ -40,32 +47,23 @@ long unsigned int pack_grid4_power(char *grid4, int power) { return m; } -long unsigned int pack_call(char *callsign) { +long unsigned int pack_call(char const *callsign) { unsigned int i; long unsigned int n; - char call6[7]; - memset(call6,32,sizeof(char)*7); + char call6[6]; + memset(call6,' ',sizeof(call6)); // callsign is 6 characters in length. Exactly. size_t call_len = strlen(callsign); if( call_len > 6 ) { return 0; } - if( isdigit(*(callsign+2)) ) { + if( isdigit(callsign[2]) ) { for (i=0; i3) & (i1<7) & (i2==mlen) & (i3==mlen) ) { + if( i1 > 3 && i1 < 7 && i2 == mlen && i3 == mlen ) { // Type 1 message: K9AN EN50 33 // xxnxxxx xxnn nn callsign = strtok(message," "); @@ -239,10 +236,10 @@ int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* sym n = pack_call(grid6); } else if ( i2 < mlen ) { // just looks for a right slash // Type 2: PJ4/K1ABC 37 - callsign=strtok(message," "); + callsign = strtok (message," "); if( i2==0 || i2>strlen(callsign) ) return 0; //guards against pathological case - powstr=strtok(NULL," "); - int power = atoi(powstr); + powstr = strtok (NULL," "); + int power = atoi (powstr); if( power < 0 ) power=0; if( power > 60 ) power=60; power=power+nu[power%10]; @@ -254,7 +251,7 @@ int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* sym } else { return 0; } - + // pack 50 bits + 31 (0) tail bits into 11 bytes unsigned char it, data[11]; memset(data,0,sizeof(char)*11); @@ -294,9 +291,10 @@ int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* sym check_callsign=malloc(sizeof(char)*13); signed char check_data[11]; memcpy(check_data,data,sizeof(char)*11); + unpk_(check_data,hashtab,check_call_loc_pow,check_callsign); // printf("Will decode as: %s\n",check_call_loc_pow); - + unsigned int nbytes=11; // The message with tail is packed into almost 11 bytes. unsigned char channelbits[nbytes*8*2]; /* 162 rounded up */ memset(channelbits,0,sizeof(char)*nbytes*8*2); diff --git a/lib/wsprd/wsprsim_utils.h b/lib/wsprd/wsprsim_utils.h index 2f4151a59..acffdee91 100644 --- a/lib/wsprd/wsprsim_utils.h +++ b/lib/wsprd/wsprsim_utils.h @@ -11,18 +11,6 @@ extern int printdata; -char get_locator_character_code(char ch); - -char get_callsign_character_code(char ch); - -long unsigned int pack_grid4_power(char *grid4, int power); - -long unsigned int pack_call(char *callsign); - -void pack_prefix(char *callsign, int32_t *n, int32_t *m, int32_t *nadd ); - -void interleave(unsigned char *sym); - int get_wspr_channel_symbols(char* message, char* hashtab, unsigned char* symbols); #endif