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
This commit is contained in:
Steven Franke 2018-02-12 01:13:03 +00:00
parent 0a21abd6bc
commit 0ce5de0f28
3 changed files with 30 additions and 44 deletions

View File

@ -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<npoints; i++) {

View File

@ -6,6 +6,13 @@
#include "nhash.h"
#include "fano.h"
static char get_locator_character_code(char ch);
static char get_callsign_character_code(char ch);
static long unsigned int pack_grid4_power(char const *grid4, int power);
static long unsigned int pack_call(char const *callsign);
static void pack_prefix(char *callsign, int32_t *n, int32_t *m, int32_t *nadd );
static void interleave(unsigned char *sym);
char get_locator_character_code(char ch) {
if( ch >=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; i<call_len; i++) {
if( callsign[i] == 0 ) {
call6[i]=32;
} else {
call6[i]=*(callsign+i);
}
call6[i]=callsign[i];
}
} else if( isdigit(*(callsign+1)) ) {
call6[0]=32;
} else if( isdigit(callsign[1]) ) {
for (i=1; i<call_len+1; i++) {
if( callsign[i-1]==0 ) {
call6[i]=32;
} else {
call6[i]=*(callsign+i-1);
}
call6[i]=callsign[i-1];
}
}
for (i=0; i<6; i++) {
@ -82,9 +80,7 @@ long unsigned int pack_call(char *callsign) {
void pack_prefix(char *callsign, int32_t *n, int32_t *m, int32_t *nadd ) {
size_t i;
char *call6;
call6=malloc(sizeof(char)*7);
memset(call6,32,sizeof(char)*7);
char * call6 = calloc(7,sizeof (char));
size_t i1=strcspn(callsign,"/");
if( callsign[i1+2] == 0 ) {
@ -92,6 +88,7 @@ void pack_prefix(char *callsign, int32_t *n, int32_t *m, int32_t *nadd ) {
for (i=0; i<i1; i++) {
call6[i]=callsign[i];
}
call6[i] = '\0';
*n=pack_call(call6);
*nadd=1;
int nc = callsign[i1+1];
@ -113,10 +110,10 @@ void pack_prefix(char *callsign, int32_t *n, int32_t *m, int32_t *nadd ) {
*m=10*(callsign[i1+1]-48)+(callsign[i1+2]-48);
*m=60000 + 26 + *m;
} else {
char* pfx=strtok(callsign,"/");
call6=strtok(NULL," ");
*n=pack_call(call6);
size_t plen=strlen(pfx);
char const * pfx = strtok (callsign,"/");
char const * call = strtok(NULL," ");
*n = pack_call (call);
size_t plen=strlen (pfx);
if( plen ==1 ) {
*m=36;
*m=37*(*m)+36;
@ -142,7 +139,7 @@ void pack_prefix(char *callsign, int32_t *n, int32_t *m, int32_t *nadd ) {
*nadd=1;
}
}
free(call6);
free (call6);
}
void interleave(unsigned char *sym)
@ -199,7 +196,7 @@ int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* sym
// Use the presence and/or absence of "<" and "/" to decide what
// type of message. No sanity checks! Beware!
if( (i1>3) & (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);

View File

@ -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