fixed bug in numbers or bits read in
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 6 Feb 2018 20:29:12 +0000 (20:29 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 6 Feb 2018 20:29:12 +0000 (20:29 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3395 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/fsk_mod_ext_vco.c

index 232da984b3005440c7a42ffe599a2c3d46df5f5a..137bdab71007c392e191a4ac8808e18a4bf197af 100644 (file)
 */
 
 #include <assert.h>
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
 
 int main(int argc,char *argv[]){
-    int   os, m, i, bit_i, sym;
+    int   os, m, log2m, i, bit_i, sym;
     float d;
     FILE *fin,*fout;
     
@@ -43,11 +44,12 @@ int main(int argc,char *argv[]){
     }
     
     /* Extract parameters */
-    m = atoi(argv[1]);
+    m = atoi(argv[1]); log2m = log2(m);
+    printf("log2m: %d\n", log2m);
     os = atoi(argv[2]);
     d = atof(argv[3]);
     
-    uint8_t tx_bits[m];
+    uint8_t tx_bits[log2m];
     int16_t rawbuf[os];
 
     if (strcmp(argv[4],"-")==0){
@@ -64,7 +66,7 @@ int main(int argc,char *argv[]){
     
     /* Modulate m bits to levels to drive external VCO */
 
-    while( fread(tx_bits, sizeof(uint8_t), m, fin) == m ){
+    while( fread(tx_bits, sizeof(uint8_t), log2m, fin) == log2m ){
 
         /* generate the symbol number from the bit stream, 
            e.g. 0,1 for 2FSK, 0,1,2,3 for 4FSK */