1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-25 22:43:14 +00:00

Fixes for 32-bit archs

This commit is contained in:
Carles Fernandez 2018-08-11 09:52:26 +02:00
parent 2b65c1b550
commit 35daf5a5e5
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
3 changed files with 18 additions and 18 deletions

View File

@ -279,26 +279,26 @@ std::string Rtcm::hex_to_bin(const std::string& s) const
}
uint64_t Rtcm::bin_to_uint(const std::string& s) const
uint32_t Rtcm::bin_to_uint(const std::string& s) const
{
if (s.length() > 32)
{
LOG(WARNING) << "Cannot convert to a uint64_t";
LOG(WARNING) << "Cannot convert to a uint32_t";
return 0;
}
uint64_t reading = strtoul(s.c_str(), NULL, 2);
uint32_t reading = strtoul(s.c_str(), NULL, 2);
return reading;
}
int64_t Rtcm::bin_to_int(const std::string& s) const
int32_t Rtcm::bin_to_int(const std::string& s) const
{
if (s.length() > 32)
{
LOG(WARNING) << "Cannot convert to a int64_t";
LOG(WARNING) << "Cannot convert to a int32_t";
return 0;
}
int64_t reading;
int32_t reading;
// Handle negative numbers
if (s.substr(0, 1).compare("0"))
@ -316,15 +316,15 @@ int64_t Rtcm::bin_to_int(const std::string& s) const
}
int64_t Rtcm::bin_to_sint(const std::string& s) const
int32_t Rtcm::bin_to_sint(const std::string& s) const
{
if (s.length() > 32)
{
LOG(WARNING) << "Cannot convert to a int64_t";
LOG(WARNING) << "Cannot convert to a int32_t";
return 0;
}
int64_t reading;
int64_t sign;
int32_t reading;
int32_t sign;
// Check for sign bit as defined RTCM doc
if (s.substr(0, 1).compare("0") == 0)
@ -4079,7 +4079,7 @@ int Rtcm::set_DF052(const Gps_Ephemeris& gps_eph, double obs_time)
std::string minutes = now_ptime.substr(11, 2);
std::string seconds = now_ptime.substr(13, 8);
//boost::gregorian::date d(boost::gregorian::from_undelimited_string(today_ptime));
uint64_t seconds_of_day = boost::lexical_cast<unsigned int>(hours) * 60 * 60 + boost::lexical_cast<unsigned int>(minutes) * 60 + boost::lexical_cast<unsigned int>(seconds);
uint32_t seconds_of_day = boost::lexical_cast<unsigned int>(hours) * 60 * 60 + boost::lexical_cast<unsigned int>(minutes) * 60 + boost::lexical_cast<unsigned int>(seconds);
DF052 = std::bitset<17>(seconds_of_day);
return 0;
}

View File

@ -348,8 +348,8 @@ public:
std::string bin_to_binary_data(const std::string& s) const; //<! Returns a string of binary data from a string of binary symbols
std::string binary_data_to_bin(const std::string& s) const; //<! Returns a string of binary symbols from a string of binary data
uint64_t bin_to_uint(const std::string& s) const; //<! Returns an uint64_t from a string of binary symbols
int64_t bin_to_int(const std::string& s) const;
uint32_t bin_to_uint(const std::string& s) const; //<! Returns an uint32_t from a string of binary symbols
int32_t bin_to_int(const std::string& s) const;
double bin_to_double(const std::string& s) const; //<! Returns double from a string of binary symbols
/*!
* \brief Locks time period in which GLONASS signals have been continually tracked.
@ -359,7 +359,7 @@ public:
* \param observables Set of observables as defined by the platform
* \return //<! Returns a int64_t from a string of binary symbols
*/
int64_t bin_to_sint(const std::string& s) const;
int32_t bin_to_sint(const std::string& s) const;
uint64_t hex_to_uint(const std::string& s) const; //<! Returns an uint64_t from a string of hexadecimal symbols
int64_t hex_to_int(const std::string& s) const; //<! Returns a int64_t from a string of hexadecimal symbols

View File

@ -137,9 +137,9 @@ TEST(RtcmTest, BinToDouble)
TEST(RtcmTest, BinToUint)
{
auto rtcm = std::make_shared<Rtcm>();
uint64_t expected1 = 42;
uint32_t expected1 = 42;
EXPECT_EQ(expected1, rtcm->bin_to_uint("00101010"));
uint64_t expected2 = 214;
uint32_t expected2 = 214;
EXPECT_EQ(expected2, rtcm->bin_to_uint("11010110"));
}
@ -147,9 +147,9 @@ TEST(RtcmTest, BinToUint)
TEST(RtcmTest, BinToInt)
{
auto rtcm = std::make_shared<Rtcm>();
int64_t expected1 = 42;
int32_t expected1 = 42;
EXPECT_EQ(expected1, rtcm->bin_to_int("00101010"));
int64_t expected2 = -42;
int32_t expected2 = -42;
EXPECT_EQ(expected2, rtcm->bin_to_int("11010110"));
}