mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-13 19:50:34 +00:00
code cleaning
This commit is contained in:
parent
078260d83f
commit
cb1fd9e727
@ -34,14 +34,11 @@
|
||||
#include <string>
|
||||
|
||||
|
||||
void
|
||||
galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn,
|
||||
unsigned int _chip_shift)
|
||||
void galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn, unsigned int _chip_shift)
|
||||
{
|
||||
std::string _galileo_signal = _Signal;
|
||||
signed int prn = _prn - 1;
|
||||
int index = 0;
|
||||
//int* dest = _dest;
|
||||
|
||||
/* A simple error check */
|
||||
if ((_prn < 1) || (_prn > 50))
|
||||
@ -53,8 +50,7 @@ galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn,
|
||||
{
|
||||
for (size_t i = 0; i < Galileo_E1_B_PRIMARY_CODE[prn].length(); i++)
|
||||
{
|
||||
hex_to_binary_converter(&_dest[index],
|
||||
Galileo_E1_B_PRIMARY_CODE[prn].at(i));
|
||||
hex_to_binary_converter(&_dest[index], Galileo_E1_B_PRIMARY_CODE[prn].at(i));
|
||||
index = index + 4;
|
||||
}
|
||||
|
||||
@ -63,9 +59,8 @@ galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn,
|
||||
{
|
||||
for (size_t i = 0; i < Galileo_E1_C_PRIMARY_CODE[prn].length(); i++)
|
||||
{
|
||||
hex_to_binary_converter(&_dest[index],
|
||||
Galileo_E1_C_PRIMARY_CODE[prn].at(i));
|
||||
index = index +4;
|
||||
hex_to_binary_converter(&_dest[index], Galileo_E1_C_PRIMARY_CODE[prn].at(i));
|
||||
index = index + 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -76,29 +71,26 @@ galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn,
|
||||
|
||||
|
||||
|
||||
void
|
||||
galileo_e1_sinboc_11_gen(std::complex<float>* _dest, int* _prn,
|
||||
unsigned int _length_out)
|
||||
void galileo_e1_sinboc_11_gen(std::complex<float>* _dest, int* _prn, unsigned int _length_out)
|
||||
{
|
||||
const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS;
|
||||
unsigned int _period = (unsigned int) (_length_out / _length_in);
|
||||
for (unsigned int i = 0; i < _length_in; i++)
|
||||
{
|
||||
for (unsigned int j = 0; j < (_period / 2); j++)
|
||||
_dest[i * _period + j] = std::complex<float>((float) _prn[i],
|
||||
0.0);
|
||||
|
||||
{
|
||||
_dest[i * _period + j] = std::complex<float>((float) _prn[i], 0.0);
|
||||
}
|
||||
for (unsigned int j = (_period / 2); j < _period; j++)
|
||||
_dest[i * _period + j] = std::complex<float>((float) (-_prn[i]),
|
||||
0.0);
|
||||
{
|
||||
_dest[i * _period + j] = std::complex<float>((float) (- _prn[i]), 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
galileo_e1_sinboc_61_gen(std::complex<float>* _dest, int* _prn,
|
||||
unsigned int _length_out)
|
||||
void galileo_e1_sinboc_61_gen(std::complex<float>* _dest, int* _prn, unsigned int _length_out)
|
||||
{
|
||||
const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS;
|
||||
unsigned int _period = (unsigned int) (_length_out / _length_in);
|
||||
@ -106,26 +98,27 @@ galileo_e1_sinboc_61_gen(std::complex<float>* _dest, int* _prn,
|
||||
for (unsigned int i = 0; i < _length_in; i++)
|
||||
{
|
||||
for (unsigned int j = 0; j < _period; j += 2)
|
||||
_dest[i * _period + j] = std::complex<float>((float) _prn[i],
|
||||
0.0);
|
||||
{
|
||||
_dest[i * _period + j] = std::complex<float>((float) _prn[i], 0.0);
|
||||
}
|
||||
for (unsigned int j = 1; j < _period; j += 2)
|
||||
_dest[i * _period + j] = std::complex<float>((float) (-_prn[i]),
|
||||
0.0);
|
||||
{
|
||||
_dest[i * _period + j] = std::complex<float>((float) (- _prn[i]), 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3])
|
||||
void galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3])
|
||||
{
|
||||
std::string _galileo_signal = _Signal;
|
||||
const unsigned int _codeLength = 12 * Galileo_E1_B_CODE_LENGTH_CHIPS;
|
||||
const float alpha = sqrt(10.0 / 11.0);
|
||||
const float beta = sqrt(1.0 / 11.0);
|
||||
|
||||
std::complex<float> sinboc_11[12*4092]; // _codeLength not accepted by Clang
|
||||
std::complex<float> sinboc_61[12*4092];
|
||||
std::complex<float> sinboc_11[12 * 4092]; // _codeLength not accepted by Clang
|
||||
std::complex<float> sinboc_61[12 * 4092];
|
||||
|
||||
galileo_e1_sinboc_11_gen(sinboc_11, _prn, _codeLength); //generate sinboc(1,1) 12 samples per chip
|
||||
galileo_e1_sinboc_61_gen(sinboc_61, _prn, _codeLength); //generate sinboc(6,1) 12 samples per chip
|
||||
@ -150,14 +143,11 @@ galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3])
|
||||
|
||||
|
||||
|
||||
void
|
||||
galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
|
||||
void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
|
||||
bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift,
|
||||
bool _secondary_flag)
|
||||
{
|
||||
|
||||
// This function is based on the GNU software GPS for MATLAB in Kay Borre's book
|
||||
|
||||
std::string _galileo_signal = _Signal;
|
||||
unsigned int _samplesPerCode;
|
||||
const int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz
|
||||
@ -183,8 +173,7 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
|
||||
}
|
||||
else
|
||||
{
|
||||
galileo_e1_sinboc_11_gen(_signal_E1, primary_code_E1_chips,
|
||||
_codeLength); //generate sinboc(1,1) 2 samples per chip
|
||||
galileo_e1_sinboc_11_gen(_signal_E1, primary_code_E1_chips, _codeLength); //generate sinboc(1,1) 2 samples per chip
|
||||
}
|
||||
|
||||
if (_fs != _samplesPerChip * _codeFreqBasis)
|
||||
@ -223,17 +212,15 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
|
||||
|
||||
for (unsigned int i = 0; i < _samplesPerCode; i++)
|
||||
{
|
||||
_dest[(i+delay)%_samplesPerCode] = _signal_E1[i];
|
||||
_dest[(i + delay) % _samplesPerCode] = _signal_E1[i];
|
||||
}
|
||||
|
||||
delete[] _signal_E1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
|
||||
void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
|
||||
bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift)
|
||||
{
|
||||
galileo_e1_code_gen_complex_sampled(_dest, _Signal, _cboc, _prn,
|
||||
_fs, _chip_shift, false);
|
||||
galileo_e1_code_gen_complex_sampled(_dest, _Signal, _cboc, _prn, _fs, _chip_shift, false);
|
||||
}
|
||||
|
@ -35,71 +35,63 @@
|
||||
|
||||
void galileo_e5_a_code_gen_complex_primary(std::complex<float>* _dest, signed int _prn, char _Signal[3])
|
||||
{
|
||||
unsigned int prn=_prn-1;
|
||||
unsigned int index=0;
|
||||
unsigned int prn = _prn - 1;
|
||||
unsigned int index = 0;
|
||||
int a[4];
|
||||
if ((_prn < 1) || (_prn > 50))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_Signal[0]=='5' && _Signal[1]=='Q')
|
||||
if (_Signal[0] == '5' && _Signal[1] == 'Q')
|
||||
{
|
||||
for (size_t i = 0; i < Galileo_E5a_Q_PRIMARY_CODE[prn].length()-1; i++)
|
||||
for (size_t i = 0; i < Galileo_E5a_Q_PRIMARY_CODE[prn].length() - 1; i++)
|
||||
{
|
||||
hex_to_binary_converter(a,
|
||||
Galileo_E5a_Q_PRIMARY_CODE[prn].at(i));
|
||||
_dest[index]=std::complex<float>(0.0,float(a[0]));
|
||||
_dest[index+1]=std::complex<float>(0.0,float(a[1]));
|
||||
_dest[index+2]=std::complex<float>(0.0,float(a[2]));
|
||||
_dest[index+3]=std::complex<float>(0.0,float(a[3]));
|
||||
hex_to_binary_converter(a, Galileo_E5a_Q_PRIMARY_CODE[prn].at(i));
|
||||
_dest[index] = std::complex<float>(0.0, float(a[0]));
|
||||
_dest[index + 1] = std::complex<float>(0.0, float(a[1]));
|
||||
_dest[index + 2] = std::complex<float>(0.0, float(a[2]));
|
||||
_dest[index + 3] = std::complex<float>(0.0, float(a[3]));
|
||||
index = index + 4;
|
||||
}
|
||||
// last 2 bits are filled up zeros
|
||||
hex_to_binary_converter(a,
|
||||
Galileo_E5a_Q_PRIMARY_CODE[prn].at(Galileo_E5a_Q_PRIMARY_CODE[prn].length()-1));
|
||||
_dest[index]=std::complex<float>(float(0.0),a[0]);
|
||||
_dest[index+1]=std::complex<float>(float(0.0),a[1]);
|
||||
hex_to_binary_converter(a, Galileo_E5a_Q_PRIMARY_CODE[prn].at(Galileo_E5a_Q_PRIMARY_CODE[prn].length() - 1));
|
||||
_dest[index] = std::complex<float>(float(0.0), a[0]);
|
||||
_dest[index + 1] = std::complex<float>(float(0.0), a[1]);
|
||||
}
|
||||
else if (_Signal[0]=='5' && _Signal[1]=='I')
|
||||
else if (_Signal[0] == '5' && _Signal[1] == 'I')
|
||||
{
|
||||
for (size_t i = 0; i < Galileo_E5a_I_PRIMARY_CODE[prn].length()-1; i++)
|
||||
for (size_t i = 0; i < Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1; i++)
|
||||
{
|
||||
hex_to_binary_converter(a,
|
||||
Galileo_E5a_I_PRIMARY_CODE[prn].at(i));
|
||||
_dest[index]=std::complex<float>(float(a[0]),0.0);
|
||||
_dest[index+1]=std::complex<float>(float(a[1]),0.0);
|
||||
_dest[index+2]=std::complex<float>(float(a[2]),0.0);
|
||||
_dest[index+3]=std::complex<float>(float(a[3]),0.0);
|
||||
hex_to_binary_converter(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(i));
|
||||
_dest[index] = std::complex<float>(float(a[0]), 0.0);
|
||||
_dest[index + 1] = std::complex<float>(float(a[1]), 0.0);
|
||||
_dest[index + 2] = std::complex<float>(float(a[2]), 0.0);
|
||||
_dest[index + 3] = std::complex<float>(float(a[3]), 0.0);
|
||||
index = index + 4;
|
||||
}
|
||||
// last 2 bits are filled up zeros
|
||||
hex_to_binary_converter(a,
|
||||
Galileo_E5a_I_PRIMARY_CODE[prn].at(Galileo_E5a_I_PRIMARY_CODE[prn].length()-1));
|
||||
_dest[index]=std::complex<float>(float(a[0]),0.0);
|
||||
_dest[index+1]=std::complex<float>(float(a[1]),0.0);
|
||||
hex_to_binary_converter(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1));
|
||||
_dest[index] = std::complex<float>(float(a[0]), 0.0);
|
||||
_dest[index + 1] = std::complex<float>(float(a[1]), 0.0);
|
||||
}
|
||||
else if (_Signal[0]=='5' && _Signal[1]=='X')
|
||||
else if (_Signal[0] == '5' && _Signal[1] == 'X')
|
||||
{
|
||||
int b[4];
|
||||
for (size_t i = 0; i < Galileo_E5a_I_PRIMARY_CODE[prn].length()-1; i++)
|
||||
for (size_t i = 0; i < Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1; i++)
|
||||
{
|
||||
hex_to_binary_converter(a,
|
||||
Galileo_E5a_I_PRIMARY_CODE[prn].at(i));
|
||||
hex_to_binary_converter(b,
|
||||
Galileo_E5a_Q_PRIMARY_CODE[prn].at(i));
|
||||
_dest[index]=std::complex<float>(float(a[0]),float(b[0]));
|
||||
_dest[index+1]=std::complex<float>(float(a[1]),float(b[1]));
|
||||
_dest[index+2]=std::complex<float>(float(a[2]),float(b[2]));
|
||||
_dest[index+3]=std::complex<float>(float(a[3]),float(b[3]));
|
||||
hex_to_binary_converter(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(i));
|
||||
hex_to_binary_converter(b, Galileo_E5a_Q_PRIMARY_CODE[prn].at(i));
|
||||
_dest[index] = std::complex<float>(float(a[0]),float(b[0]));
|
||||
_dest[index + 1] = std::complex<float>(float(a[1]),float(b[1]));
|
||||
_dest[index + 2] = std::complex<float>(float(a[2]),float(b[2]));
|
||||
_dest[index + 3] = std::complex<float>(float(a[3]),float(b[3]));
|
||||
index = index + 4;
|
||||
}
|
||||
// last 2 bits are filled up zeros
|
||||
hex_to_binary_converter(a,
|
||||
Galileo_E5a_I_PRIMARY_CODE[prn].at(Galileo_E5a_I_PRIMARY_CODE[prn].length()-1));
|
||||
hex_to_binary_converter(b,
|
||||
Galileo_E5a_Q_PRIMARY_CODE[prn].at(Galileo_E5a_Q_PRIMARY_CODE[prn].length()-1));
|
||||
_dest[index]=std::complex<float>(float(a[0]),float(b[0]));
|
||||
_dest[index+1]=std::complex<float>(float(a[1]),float(b[1]));
|
||||
hex_to_binary_converter(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1));
|
||||
hex_to_binary_converter(b, Galileo_E5a_Q_PRIMARY_CODE[prn].at(Galileo_E5a_Q_PRIMARY_CODE[prn].length() - 1));
|
||||
_dest[index] = std::complex<float>(float(a[0]), float(b[0]));
|
||||
_dest[index + 1] = std::complex<float>(float(a[1]), float(b[1]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,39 +99,33 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest, char _Sig
|
||||
unsigned int _prn, signed int _fs, unsigned int _chip_shift)
|
||||
{
|
||||
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
|
||||
|
||||
unsigned int _samplesPerCode;
|
||||
unsigned int delay;
|
||||
unsigned int _codeLength = Galileo_E5a_CODE_LENGTH_CHIPS;
|
||||
const int _codeFreqBasis = Galileo_E5a_CODE_CHIP_RATE_HZ; //Hz
|
||||
|
||||
|
||||
std::complex<float>* _code;
|
||||
_code=new std::complex<float>[_codeLength];
|
||||
_code = new std::complex<float>[_codeLength];
|
||||
|
||||
galileo_e5_a_code_gen_complex_primary(_code , _prn , _Signal);
|
||||
|
||||
_samplesPerCode = round(_fs / (_codeFreqBasis / _codeLength));
|
||||
|
||||
delay = ((_codeLength - _chip_shift)
|
||||
% _codeLength) * _samplesPerCode / _codeLength;
|
||||
|
||||
delay = ((_codeLength - _chip_shift) % _codeLength) * _samplesPerCode / _codeLength;
|
||||
|
||||
if (_fs != _codeFreqBasis)
|
||||
{
|
||||
std::complex<float>* _resampled_signal;
|
||||
if (posix_memalign((void**)&_resampled_signal, 16, _samplesPerCode * sizeof(gr_complex)) == 0){};
|
||||
resampler(_code, _resampled_signal, _codeFreqBasis, _fs,
|
||||
_codeLength, _samplesPerCode); //resamples code to fs
|
||||
resampler(_code, _resampled_signal, _codeFreqBasis, _fs, _codeLength, _samplesPerCode); //resamples code to fs
|
||||
delete[] _code;
|
||||
_code = _resampled_signal;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < _samplesPerCode; i++)
|
||||
{
|
||||
_dest[(i+delay)%_samplesPerCode] = _code[i];
|
||||
_dest[(i + delay) % _samplesPerCode] = _code[i];
|
||||
}
|
||||
|
||||
free(_code);
|
||||
|
||||
}
|
||||
|
@ -178,9 +178,9 @@ void resampler(std::complex<float>* _from, std::complex<float>* _dest, float _fs
|
||||
{
|
||||
unsigned int _codeValueIndex;
|
||||
//--- Find time constants --------------------------------------------------
|
||||
const float _t_in = 1/_fs_in; // Incoming sampling period in sec
|
||||
const float _t_out = 1/_fs_out; // Out sampling period in sec
|
||||
for (unsigned int i=0; i<_length_out-1; i++)
|
||||
const float _t_in = 1 / _fs_in; // Incoming sampling period in sec
|
||||
const float _t_out = 1 / _fs_out; // Out sampling period in sec
|
||||
for (unsigned int i = 0; i < _length_out - 1; i++)
|
||||
{
|
||||
//=== Digitizing =======================================================
|
||||
//--- compute index array to read sampled values -------------------------
|
||||
@ -189,5 +189,5 @@ void resampler(std::complex<float>* _from, std::complex<float>* _dest, float _fs
|
||||
_dest[i] = _from[_codeValueIndex];
|
||||
}
|
||||
//--- Correct the last index (due to number rounding issues) -----------
|
||||
_dest[_length_out-1] = _from[_length_in - 1];
|
||||
_dest[_length_out - 1] = _from[_length_in - 1];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user