diff --git a/lib/wsprd/fano.c b/lib/wsprd/fano.c index bf2603a45..8fe1a649e 100644 --- a/lib/wsprd/fano.c +++ b/lib/wsprd/fano.c @@ -60,7 +60,7 @@ struct node { * and easier than trying to pack them more compactly. */ int encode( - unsigned char *symbols, // Output buffer, 2*nbytes + unsigned char *symbols, // Output buffer, 2*nbytes*8 unsigned char *data, // Input buffer, nbytes unsigned int nbytes) // Number of bytes in data { @@ -69,7 +69,7 @@ int encode( int i; encstate = 0; - while(--nbytes != 0) { + while(nbytes-- != 0) { for(i=7;i>=0;i--) { encstate = (encstate << 1) | ((*data >> i) & 1); ENCODE(sym,encstate); diff --git a/lib/wsprd/wsprsim_utils.c b/lib/wsprd/wsprsim_utils.c index a42b1cfa7..49a118c03 100644 --- a/lib/wsprd/wsprsim_utils.c +++ b/lib/wsprd/wsprsim_utils.c @@ -296,10 +296,9 @@ int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* sym 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 11 bytes. - unsigned int nencoded=162; - unsigned char channelbits[nencoded]; - memset(channelbits,0,sizeof(char)*nencoded); + 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 channelbits); encode(channelbits,data,nbytes);