diff --git a/gpssim.c b/gpssim.c index 49436b7..fb75ee5 100644 --- a/gpssim.c +++ b/gpssim.c @@ -225,7 +225,7 @@ typedef struct double f_carr; /*< Carrier frequency */ double f_code; /*< Code frequency */ unsigned int carr_phase; /*< Carrier phase */ - int carr_phasestep; /*< Carrier phasestep */ + int carr_phasestep; /*< Carrier phasestep */ double code_phase; /*< Code phase */ gpstime_t g0; /*!< GPS time at start */ unsigned long dwrd[N_DWRD]; /*!< Data words of sub-frame */ @@ -1570,22 +1570,22 @@ int main(int argc, char *argv[]) //////////////////////////////////////////////////////////// // Allocate I/Q buffer - iq_buff = calloc(2*iq_buff_size, 2); + iq_buff = calloc(2*iq_buff_size, 2); if (iq_buff==NULL) { printf("Faild to allocate IQ buffer.\n"); exit(1); } - if (data_format==SC08) - { - iq8_buff = calloc(2*iq_buff_size, 1); - if (iq8_buff==NULL) - { - printf("Faild to allocate IQ buffer.\n"); - exit(1); - } - } + if (data_format==SC08) + { + iq8_buff = calloc(2*iq_buff_size, 1); + if (iq8_buff==NULL) + { + printf("Faild to allocate IQ buffer.\n"); + exit(1); + } + } // Open output file if (NULL==(fp=fopen(outfile,"wb"))) @@ -1624,8 +1624,8 @@ int main(int argc, char *argv[]) r_xyz = tmp.range; phase_ini = (2.0*r_ref - r_xyz)/LAMBDA_L1; - phase_ini -= floor(phase_ini); - chan[i].carr_phase = 512 * 65536.0 * phase_ini; + phase_ini -= floor(phase_ini); + chan[i].carr_phase = (unsigned int)(512 * 65536.0 * phase_ini); } //////////////////////////////////////////////////////////// @@ -1695,8 +1695,6 @@ int main(int argc, char *argv[]) for (iumd=1; iumd Configuration Properties -> C/C++ -> Language -> Open MP Support -> Yes (/openmp) for (i=0; i> 16) & 511; + iTable = (chan[i].carr_phase >> 16) & 511; ip = chan[i].dataBit * chan[i].codeCA * cosTable512[iTable]; qp = chan[i].dataBit * chan[i].codeCA * sinTable512[iTable]; - i_acc += ip; - q_acc += qp; + i_acc += ip; + q_acc += qp; #else ip = chan[i].dataBit * chan[i].codeCA * cos(2.0*PI*chan[i].carr_phase); qp = chan[i].dataBit * chan[i].codeCA * sin(2.0*PI*chan[i].carr_phase); @@ -1769,17 +1767,17 @@ int main(int argc, char *argv[]) chan[i].carr_phase += chan[i].carr_phasestep; } - // Store I/Q samples into buffer - iq_buff[isamp*2] = (short)i_acc; - iq_buff[isamp*2+1] = (short)q_acc; - + // Store I/Q samples into buffer + iq_buff[isamp*2] = (short)i_acc; + iq_buff[isamp*2+1] = (short)q_acc; + } // End of omp parallel for if (data_format==SC08) { for (isamp=0; isamp<2*iq_buff_size; isamp++) { - iq8_buff[isamp] = iq_buff[isamp]>>4; // 12-bit bladeRF -> 8-bit HackRF + iq8_buff[isamp] = iq_buff[isamp]>>4; // 12-bit bladeRF -> 8-bit HackRF } fwrite(iq8_buff, 1, 2*iq_buff_size, fp); }