1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 04:30:33 +00:00

Fixes for 32 bits architectures

This commit is contained in:
Carles Fernandez 2018-08-14 13:31:37 +02:00
parent b64850d285
commit e381f75fd3
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
5 changed files with 64 additions and 180 deletions

View File

@ -364,7 +364,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
}
else if (d_stat == 1) // check 6 seconds of preamble separation
{
preamble_diff_ms = std::round(((static_cast<double>(d_symbol_history.at(0).Tracking_sample_counter) - d_preamble_time_samples) / static_cast<double>(d_symbol_history.at(0).fs)) * 1000.0);
preamble_diff_ms = std::round(((static_cast<double>(d_symbol_history.at(0).Tracking_sample_counter) - static_cast<double>(d_preamble_time_samples)) / static_cast<double>(d_symbol_history.at(0).fs)) * 1000.0);
if (std::abs(preamble_diff_ms - GPS_SUBFRAME_MS) % GPS_SUBFRAME_MS == 0)
{
DLOG(INFO) << "Preamble confirmation for SAT " << this->d_satellite;

View File

@ -434,7 +434,7 @@ void Galileo_Fnav_Message::decode_page(std::string data)
uint64_t Galileo_Fnav_Message::read_navigation_unsigned(std::bitset<GALILEO_FNAV_DATA_FRAME_BITS> bits, const std::vector<std::pair<int32_t, int32_t>> parameter)
{
uint64_t value = 0;
uint64_t value = 0ULL;
int num_of_slices = parameter.size();
for (int i = 0; i < num_of_slices; i++)
{
@ -453,12 +453,9 @@ uint64_t Galileo_Fnav_Message::read_navigation_unsigned(std::bitset<GALILEO_FNAV
int64_t Galileo_Fnav_Message::read_navigation_signed(std::bitset<GALILEO_FNAV_DATA_FRAME_BITS> bits, const std::vector<std::pair<int32_t, int32_t>> parameter)
{
int64_t value = 0;
int64_t value = 0LL;
int num_of_slices = parameter.size();
// Discriminate between 64 bits and 32 bits compiler
int long_int_size_bytes = sizeof(long int);
if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system
{
// read the MSB and perform the sign extension
if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[0].first] == 1)
{
@ -481,32 +478,6 @@ int64_t Galileo_Fnav_Message::read_navigation_signed(std::bitset<GALILEO_FNAV_DA
}
}
}
}
else // we assume we are in a 32 bits system
{
// read the MSB and perform the sign extension
if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[0].first] == 1)
{
value ^= 0xFFFFFFFF;
}
else
{
value &= 0;
}
for (int i = 0; i < num_of_slices; i++)
{
for (int j = 0; j < parameter[i].second; j++)
{
value <<= 1; // shift left
value &= 0xFFFFFFFE; // reset the corresponding bit
if (bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j] == 1)
{
value += 1; // insert the bit
}
}
}
}
return value;
}

View File

@ -281,7 +281,7 @@ uint64_t Galileo_Navigation_Message::read_navigation_unsigned(std::bitset<GALILE
uint64_t Galileo_Navigation_Message::read_page_type_unsigned(std::bitset<GALILEO_PAGE_TYPE_BITS> bits, const std::vector<std::pair<int32_t, int32_t> > parameter)
{
uint64_t value = 0;
uint64_t value = 0ULL;
int32_t num_of_slices = parameter.size();
for (int32_t i = 0; i < num_of_slices; i++)
{
@ -300,12 +300,9 @@ uint64_t Galileo_Navigation_Message::read_page_type_unsigned(std::bitset<GALILEO
int64_t Galileo_Navigation_Message::read_navigation_signed(std::bitset<GALILEO_DATA_JK_BITS> bits, const std::vector<std::pair<int32_t, int32_t> > parameter)
{
int64_t value = 0;
int64_t value = 0LL;
int32_t num_of_slices = parameter.size();
// Discriminate between 64 bits and 32 bits compiler
int32_t long_int_size_bytes = sizeof(long int);
if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system
{
// read the MSB and perform the sign extension
if (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1)
{
@ -328,32 +325,6 @@ int64_t Galileo_Navigation_Message::read_navigation_signed(std::bitset<GALILEO_D
}
}
}
}
else // we assume we are in a 32 bits system
{
// read the MSB and perform the sign extension
if (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1)
{
value ^= 0xFFFFFFFF;
}
else
{
value &= 0;
}
for (int32_t i = 0; i < num_of_slices; i++)
{
for (int32_t j = 0; j < parameter[i].second; j++)
{
value <<= 1; // shift left
value &= 0xFFFFFFFE; // reset the corresponding bit
if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1)
{
value += 1; // insert the bit
}
}
}
}
return value;
}

View File

@ -90,7 +90,7 @@ bool Gps_CNAV_Navigation_Message::read_navigation_bool(std::bitset<GPS_CNAV_DATA
uint64_t Gps_CNAV_Navigation_Message::read_navigation_unsigned(std::bitset<GPS_CNAV_DATA_PAGE_BITS> bits, const std::vector<std::pair<int32_t, int32_t>> parameter)
{
uint64_t value = 0;
uint64_t value = 0ULL;
int32_t num_of_slices = parameter.size();
for (int32_t i = 0; i < num_of_slices; i++)
{
@ -109,12 +109,9 @@ uint64_t Gps_CNAV_Navigation_Message::read_navigation_unsigned(std::bitset<GPS_C
int64_t Gps_CNAV_Navigation_Message::read_navigation_signed(std::bitset<GPS_CNAV_DATA_PAGE_BITS> bits, const std::vector<std::pair<int32_t, int32_t>> parameter)
{
int64_t value = 0;
int64_t value = 0LL;
int32_t num_of_slices = parameter.size();
// Discriminate between 64 bits and 32 bits compiler
int32_t long_int_size_bytes = sizeof(long int);
if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system
{
// read the MSB and perform the sign extension
if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first] == 1)
{
@ -137,32 +134,6 @@ int64_t Gps_CNAV_Navigation_Message::read_navigation_signed(std::bitset<GPS_CNAV
}
}
}
}
else // we assume we are in a 32 bits system
{
// read the MSB and perform the sign extension
if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first] == 1)
{
value ^= 0xFFFFFFFF;
}
else
{
value &= 0;
}
for (int32_t i = 0; i < num_of_slices; i++)
{
for (int32_t j = 0; j < parameter[i].second; j++)
{
value <<= 1; // shift left
value &= 0xFFFFFFFE; // reset the corresponding bit
if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j] == 1)
{
value += 1; // insert the bit
}
}
}
}
return value;
}

View File

@ -197,12 +197,9 @@ uint64_t Gps_Navigation_Message::read_navigation_unsigned(std::bitset<GPS_SUBFRA
int64_t Gps_Navigation_Message::read_navigation_signed(std::bitset<GPS_SUBFRAME_BITS> bits, const std::vector<std::pair<int32_t, int32_t>> parameter)
{
int64_t value = 0ULL;
int64_t value = 0LL;
int32_t num_of_slices = parameter.size();
// Discriminate between 64 bits and 32 bits compiler
int32_t long_int_size_bytes = sizeof(long int);
if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system
{
// read the MSB and perform the sign extension
if (bits[GPS_SUBFRAME_BITS - parameter[0].first] == 1)
{
@ -225,32 +222,6 @@ int64_t Gps_Navigation_Message::read_navigation_signed(std::bitset<GPS_SUBFRAME_
}
}
}
}
else // we assume we are in a 32 bits system
{
// read the MSB and perform the sign extension
if (bits[GPS_SUBFRAME_BITS - parameter[0].first] == 1)
{
value ^= 0xFFFFFFFF;
}
else
{
value &= 0;
}
for (int32_t i = 0; i < num_of_slices; i++)
{
for (int32_t j = 0; j < parameter[i].second; j++)
{
value <<= 1; // shift left
value &= 0xFFFFFFFE; // reset the corresponding bit
if (bits[GPS_SUBFRAME_BITS - parameter[i].first - j] == 1)
{
value += 1; // insert the bit
}
}
}
}
return value;
}