2015-11-22 13:43:52 +00:00
|
|
|
/*!
|
|
|
|
* \file rtcm_test.cc
|
|
|
|
* \brief This file implements unit tests for the Rtcm class.
|
|
|
|
* \author Carles Fernandez-Prades, 2015. cfernandez(at)cttc.es
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2018-05-13 20:49:11 +00:00
|
|
|
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
2015-11-22 13:43:52 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-05-13 20:49:11 +00:00
|
|
|
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
2015-11-22 13:43:52 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2018-12-09 21:00:09 +00:00
|
|
|
#include "Galileo_E1.h"
|
|
|
|
#include "rtcm.h"
|
2015-11-22 13:43:52 +00:00
|
|
|
#include <memory>
|
2015-12-15 14:04:58 +00:00
|
|
|
#include <thread>
|
2015-11-22 13:43:52 +00:00
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, HexToBin)
|
2015-11-22 13:43:52 +00:00
|
|
|
{
|
2015-11-23 00:47:21 +00:00
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2015-11-22 13:43:52 +00:00
|
|
|
|
|
|
|
std::string test1 = "2A";
|
|
|
|
std::string test1_bin = rtcm->hex_to_bin(test1);
|
|
|
|
EXPECT_EQ(0, test1_bin.compare("00101010"));
|
|
|
|
|
|
|
|
std::string test2 = "FF";
|
|
|
|
std::string test2_bin = rtcm->hex_to_bin(test2);
|
|
|
|
EXPECT_EQ(0, test2_bin.compare("11111111"));
|
|
|
|
|
|
|
|
std::string test3 = "ff";
|
|
|
|
std::string test3_bin = rtcm->hex_to_bin(test3);
|
|
|
|
EXPECT_EQ(0, test3_bin.compare("11111111"));
|
|
|
|
|
|
|
|
std::string test4 = "100";
|
|
|
|
std::string test4_bin = rtcm->hex_to_bin(test4);
|
|
|
|
EXPECT_EQ(0, test4_bin.compare("000100000000"));
|
|
|
|
|
|
|
|
std::string test5 = "1101";
|
|
|
|
std::string test5_bin = rtcm->hex_to_bin(test5);
|
|
|
|
EXPECT_EQ(0, test5_bin.compare("0001000100000001"));
|
|
|
|
|
|
|
|
std::string test6 = "3";
|
|
|
|
std::string test6_bin = rtcm->hex_to_bin(test6);
|
|
|
|
EXPECT_EQ(0, test6_bin.compare("0011"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, BinToHex)
|
2015-11-22 13:43:52 +00:00
|
|
|
{
|
2015-11-23 00:47:21 +00:00
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2015-11-22 13:43:52 +00:00
|
|
|
|
|
|
|
std::string test1 = "00101010";
|
|
|
|
std::string test1_hex = rtcm->bin_to_hex(test1);
|
|
|
|
EXPECT_EQ(0, test1_hex.compare("2A"));
|
|
|
|
|
|
|
|
std::string test2 = "11111111";
|
|
|
|
std::string test2_hex = rtcm->bin_to_hex(test2);
|
|
|
|
EXPECT_EQ(0, test2_hex.compare("FF"));
|
|
|
|
|
|
|
|
std::string test4 = "000100000000";
|
|
|
|
std::string test4_hex = rtcm->bin_to_hex(test4);
|
|
|
|
EXPECT_EQ(0, test4_hex.compare("100"));
|
|
|
|
|
|
|
|
std::string test5 = "0001000100000001";
|
|
|
|
std::string test5_hex = rtcm->bin_to_hex(test5);
|
|
|
|
EXPECT_EQ(0, test5_hex.compare("1101"));
|
|
|
|
|
|
|
|
std::string test6 = "0011";
|
|
|
|
std::string test6_hex = rtcm->bin_to_hex(test6);
|
|
|
|
EXPECT_EQ(0, test6_hex.compare("3"));
|
|
|
|
|
|
|
|
std::string test7 = "11";
|
|
|
|
std::string test7_hex = rtcm->bin_to_hex(test7);
|
|
|
|
EXPECT_EQ(0, test7_hex.compare("3"));
|
|
|
|
|
|
|
|
std::string test8 = "1000100000001";
|
|
|
|
std::string test8_hex = rtcm->bin_to_hex(test8);
|
|
|
|
EXPECT_EQ(0, test8_hex.compare("1101"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, HexToInt)
|
2015-11-22 13:43:52 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
|
|
|
|
|
|
|
std::string test1 = "2A";
|
2018-08-10 19:16:10 +00:00
|
|
|
int64_t test1_int = rtcm->hex_to_int(test1);
|
|
|
|
int64_t expected1 = 42;
|
2015-11-22 13:43:52 +00:00
|
|
|
EXPECT_EQ(expected1, test1_int);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, HexToUint)
|
2015-11-23 00:47:21 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2018-08-10 19:16:10 +00:00
|
|
|
uint64_t expected1 = 42;
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_EQ(expected1, rtcm->hex_to_uint(rtcm->bin_to_hex("00101010")));
|
2015-11-23 00:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, BinToDouble)
|
2015-11-22 13:43:52 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
|
|
|
|
|
|
|
std::bitset<4> test1(5);
|
2018-08-10 19:16:10 +00:00
|
|
|
int64_t test1_int = static_cast<int64_t>(rtcm->bin_to_double(test1.to_string()));
|
|
|
|
int64_t expected1 = 5;
|
2015-11-22 13:43:52 +00:00
|
|
|
EXPECT_EQ(expected1, test1_int);
|
|
|
|
|
|
|
|
std::bitset<4> test2(-5);
|
|
|
|
EXPECT_DOUBLE_EQ(-5, rtcm->bin_to_double(test2.to_string()));
|
|
|
|
|
|
|
|
std::bitset<65> test3(-5);
|
|
|
|
EXPECT_DOUBLE_EQ(0, rtcm->bin_to_double(test3.to_string()));
|
|
|
|
}
|
|
|
|
|
2015-11-23 00:47:21 +00:00
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, BinToUint)
|
2015-11-23 00:47:21 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2018-08-11 07:52:26 +00:00
|
|
|
uint32_t expected1 = 42;
|
2015-11-23 00:47:21 +00:00
|
|
|
EXPECT_EQ(expected1, rtcm->bin_to_uint("00101010"));
|
2018-08-11 07:52:26 +00:00
|
|
|
uint32_t expected2 = 214;
|
2015-11-23 00:47:21 +00:00
|
|
|
EXPECT_EQ(expected2, rtcm->bin_to_uint("11010110"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, BinToInt)
|
2015-11-23 00:47:21 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2018-08-11 07:52:26 +00:00
|
|
|
int32_t expected1 = 42;
|
2015-11-23 00:47:21 +00:00
|
|
|
EXPECT_EQ(expected1, rtcm->bin_to_int("00101010"));
|
2018-08-11 07:52:26 +00:00
|
|
|
int32_t expected2 = -42;
|
2015-11-23 00:47:21 +00:00
|
|
|
EXPECT_EQ(expected2, rtcm->bin_to_int("11010110"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, BinToBinaryData)
|
2016-04-30 13:20:56 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2016-05-01 23:24:23 +00:00
|
|
|
std::string bin_str("1101101011010110");
|
2016-04-30 13:20:56 +00:00
|
|
|
std::string data_str = rtcm->bin_to_binary_data(bin_str);
|
2016-05-01 10:39:40 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
std::string test_binary = data_str.substr(0, 1);
|
2016-05-01 10:39:40 +00:00
|
|
|
std::string test_bin = rtcm->binary_data_to_bin(test_binary);
|
|
|
|
std::string test_hex = rtcm->bin_to_hex(test_bin);
|
2016-05-01 23:24:23 +00:00
|
|
|
EXPECT_EQ(0, test_hex.compare("DA"));
|
2016-05-01 10:39:40 +00:00
|
|
|
|
2016-04-30 13:20:56 +00:00
|
|
|
std::string recovered_str = rtcm->binary_data_to_bin(data_str);
|
|
|
|
EXPECT_EQ(0, recovered_str.compare(bin_str));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, CheckCRC)
|
2015-11-23 00:47:21 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2016-01-21 23:04:28 +00:00
|
|
|
bool expected_true = true;
|
|
|
|
bool expected_false = false;
|
2016-04-30 13:20:56 +00:00
|
|
|
std::string good_crc = rtcm->bin_to_binary_data(rtcm->hex_to_bin("D300133ED7D30202980EDEEF34B4BD62AC0941986F33360B98"));
|
|
|
|
std::string bad_crc = rtcm->bin_to_binary_data(rtcm->hex_to_bin("D300133ED7D30202980EDEEF34B4BD62AC0941986F33360B99"));
|
|
|
|
EXPECT_EQ(expected_true, rtcm->check_CRC(good_crc));
|
|
|
|
EXPECT_EQ(expected_false, rtcm->check_CRC(bad_crc));
|
2015-11-23 00:47:21 +00:00
|
|
|
|
2016-01-21 23:04:28 +00:00
|
|
|
EXPECT_EQ(expected_true, rtcm->check_CRC(rtcm->print_MT1005_test()));
|
|
|
|
EXPECT_EQ(expected_true, rtcm->check_CRC(rtcm->print_MT1005_test())); // Run twice to check that CRC has no memory
|
2015-11-23 00:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, MT1001)
|
2015-12-23 21:18:43 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
|
|
|
Gps_Ephemeris gps_eph = Gps_Ephemeris();
|
|
|
|
Gnss_Synchro gnss_synchro;
|
|
|
|
gnss_synchro.PRN = 2;
|
|
|
|
std::string sys = "G";
|
2016-01-21 23:04:28 +00:00
|
|
|
bool expected_true = true;
|
2016-05-06 19:00:08 +00:00
|
|
|
unsigned short station_id = 1234;
|
2015-12-23 21:18:43 +00:00
|
|
|
|
|
|
|
std::string sig = "1C";
|
|
|
|
gnss_synchro.System = *sys.c_str();
|
2017-08-19 18:05:52 +00:00
|
|
|
std::memcpy(static_cast<void*>(gnss_synchro.Signal), sig.c_str(), 3);
|
2015-12-23 21:18:43 +00:00
|
|
|
gnss_synchro.Pseudorange_m = 20000000.0;
|
|
|
|
double obs_time = 25.0;
|
|
|
|
std::map<int, Gnss_Synchro> pseudoranges;
|
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(1, gnss_synchro));
|
|
|
|
|
2016-05-06 19:00:08 +00:00
|
|
|
std::string MT1001 = rtcm->print_MT1001(gps_eph, obs_time, pseudoranges, station_id);
|
2016-01-21 23:04:28 +00:00
|
|
|
EXPECT_EQ(expected_true, rtcm->check_CRC(MT1001));
|
2015-12-23 21:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, MT1005)
|
2015-11-22 13:43:52 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2015-11-23 23:31:53 +00:00
|
|
|
std::string reference_msg = rtcm->print_MT1005_test();
|
|
|
|
std::string reference_msg2 = rtcm->print_MT1005(2003, 1114104.5999, -4850729.7108, 3975521.4643, true, false, false, false, false, 0);
|
2015-11-22 23:56:29 +00:00
|
|
|
EXPECT_EQ(0, reference_msg.compare(reference_msg2));
|
|
|
|
|
2015-11-22 13:43:52 +00:00
|
|
|
unsigned int ref_id;
|
|
|
|
double ecef_x;
|
|
|
|
double ecef_y;
|
|
|
|
double ecef_z;
|
|
|
|
bool gps;
|
|
|
|
bool glonass;
|
|
|
|
bool galileo;
|
2016-01-21 23:04:28 +00:00
|
|
|
bool expected_true = true;
|
|
|
|
bool expected_false = false;
|
2015-11-22 13:43:52 +00:00
|
|
|
|
2015-11-23 23:31:53 +00:00
|
|
|
rtcm->read_MT1005(reference_msg, ref_id, ecef_x, ecef_y, ecef_z, gps, glonass, galileo);
|
2015-11-22 13:43:52 +00:00
|
|
|
|
2016-01-21 23:04:28 +00:00
|
|
|
EXPECT_EQ(expected_true, gps);
|
|
|
|
EXPECT_EQ(expected_false, glonass);
|
|
|
|
EXPECT_EQ(expected_false, galileo);
|
2015-11-22 13:43:52 +00:00
|
|
|
|
2017-08-18 11:21:08 +00:00
|
|
|
EXPECT_EQ(static_cast<unsigned int>(2003), ref_id);
|
2015-11-22 13:43:52 +00:00
|
|
|
EXPECT_DOUBLE_EQ(1114104.5999, ecef_x);
|
|
|
|
EXPECT_DOUBLE_EQ(-4850729.7108, ecef_y);
|
|
|
|
EXPECT_DOUBLE_EQ(3975521.4643, ecef_z);
|
|
|
|
|
2016-04-30 16:16:31 +00:00
|
|
|
gps = false;
|
|
|
|
ecef_x = 0.0;
|
|
|
|
|
|
|
|
rtcm->read_MT1005(rtcm->bin_to_binary_data(rtcm->hex_to_bin("D300133ED7D30202980EDEEF34B4BD62AC0941986F33360B98")), ref_id, ecef_x, ecef_y, ecef_z, gps, glonass, galileo);
|
2015-11-22 13:43:52 +00:00
|
|
|
|
2016-01-21 23:04:28 +00:00
|
|
|
EXPECT_EQ(expected_true, gps);
|
|
|
|
EXPECT_EQ(expected_false, glonass);
|
|
|
|
EXPECT_EQ(expected_false, galileo);
|
2015-11-22 13:43:52 +00:00
|
|
|
|
2017-08-18 11:35:02 +00:00
|
|
|
EXPECT_EQ(static_cast<unsigned int>(2003), ref_id);
|
2015-11-22 13:43:52 +00:00
|
|
|
EXPECT_DOUBLE_EQ(1114104.5999, ecef_x);
|
|
|
|
EXPECT_DOUBLE_EQ(-4850729.7108, ecef_y);
|
|
|
|
EXPECT_DOUBLE_EQ(3975521.4643, ecef_z);
|
|
|
|
}
|
|
|
|
|
2015-11-23 00:47:21 +00:00
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, MT1019)
|
2015-11-22 13:43:52 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2016-01-21 23:04:28 +00:00
|
|
|
bool expected_true = true;
|
2015-11-22 13:43:52 +00:00
|
|
|
|
2015-11-23 00:47:21 +00:00
|
|
|
Gps_Ephemeris gps_eph = Gps_Ephemeris();
|
|
|
|
Gps_Ephemeris gps_eph_read = Gps_Ephemeris();
|
|
|
|
|
|
|
|
gps_eph.i_satellite_PRN = 3;
|
|
|
|
gps_eph.d_IODC = 4;
|
|
|
|
gps_eph.d_e_eccentricity = 2.0 * E_LSB;
|
|
|
|
gps_eph.b_fit_interval_flag = true;
|
2015-11-23 23:31:53 +00:00
|
|
|
std::string tx_msg = rtcm->print_MT1019(gps_eph);
|
2015-11-23 00:47:21 +00:00
|
|
|
|
2015-11-23 23:31:53 +00:00
|
|
|
EXPECT_EQ(0, rtcm->read_MT1019(tx_msg, gps_eph_read));
|
2017-08-18 11:42:27 +00:00
|
|
|
EXPECT_EQ(static_cast<unsigned int>(3), gps_eph_read.i_satellite_PRN);
|
2015-11-23 00:47:21 +00:00
|
|
|
EXPECT_DOUBLE_EQ(4, gps_eph_read.d_IODC);
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_DOUBLE_EQ(2.0 * E_LSB, gps_eph_read.d_e_eccentricity);
|
2016-01-21 23:04:28 +00:00
|
|
|
EXPECT_EQ(expected_true, gps_eph_read.b_fit_interval_flag);
|
2016-05-01 10:39:40 +00:00
|
|
|
EXPECT_EQ(1, rtcm->read_MT1019(rtcm->bin_to_binary_data(rtcm->hex_to_bin("FFFFFFFFFFF")), gps_eph_read));
|
2015-11-23 23:31:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-14 03:42:24 +00:00
|
|
|
TEST(RtcmTest, MT1020)
|
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
|
|
|
|
2017-08-19 21:04:14 +00:00
|
|
|
// Objects to populate the ephemeris and utc fields
|
2017-08-20 23:13:37 +00:00
|
|
|
Glonass_Gnav_Ephemeris gnav_ephemeris = Glonass_Gnav_Ephemeris();
|
2017-08-19 21:04:14 +00:00
|
|
|
Glonass_Gnav_Utc_Model gnav_utc_model = Glonass_Gnav_Utc_Model();
|
|
|
|
// Objects read, used for comparison
|
2017-08-20 23:13:37 +00:00
|
|
|
Glonass_Gnav_Ephemeris gnav_ephemeris_read = Glonass_Gnav_Ephemeris();
|
2017-08-19 21:04:14 +00:00
|
|
|
Glonass_Gnav_Utc_Model gnav_utc_model_read = Glonass_Gnav_Utc_Model();
|
|
|
|
|
2017-08-20 23:13:37 +00:00
|
|
|
// Perform data read and print of special values types
|
2018-03-03 01:03:39 +00:00
|
|
|
gnav_ephemeris.d_P_1 = 15;
|
2017-08-20 23:13:37 +00:00
|
|
|
// Bit distribution per fields
|
2018-03-03 01:03:39 +00:00
|
|
|
gnav_ephemeris.d_t_k = 7560;
|
2017-08-20 23:13:37 +00:00
|
|
|
// Glonass signed values
|
2018-03-03 01:03:39 +00:00
|
|
|
gnav_ephemeris.d_VXn = -0.490900039672852;
|
2018-03-25 17:47:28 +00:00
|
|
|
// Bit distribution per fields dependent on other factors
|
2018-03-03 01:03:39 +00:00
|
|
|
gnav_ephemeris.d_t_b = 8100;
|
2017-08-20 23:13:37 +00:00
|
|
|
// Binary flag representation
|
2019-02-11 12:13:54 +00:00
|
|
|
gnav_ephemeris.d_P_3 = true;
|
2017-08-20 23:13:37 +00:00
|
|
|
|
|
|
|
std::string tx_msg = rtcm->print_MT1020(gnav_ephemeris, gnav_utc_model);
|
|
|
|
|
|
|
|
EXPECT_EQ(0, rtcm->read_MT1020(tx_msg, gnav_ephemeris_read, gnav_utc_model_read));
|
|
|
|
EXPECT_EQ(gnav_ephemeris.d_P_1, gnav_ephemeris_read.d_P_1);
|
|
|
|
EXPECT_TRUE(gnav_ephemeris.d_t_b - gnav_ephemeris_read.d_t_b < FLT_EPSILON);
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_TRUE(gnav_ephemeris.d_VXn - gnav_ephemeris_read.d_VXn < FLT_EPSILON);
|
|
|
|
EXPECT_TRUE(gnav_ephemeris.d_t_k - gnav_ephemeris.d_t_k < FLT_EPSILON);
|
2017-08-20 23:13:37 +00:00
|
|
|
EXPECT_EQ(gnav_ephemeris.d_P_3, gnav_ephemeris_read.d_P_3);
|
|
|
|
EXPECT_EQ(1, rtcm->read_MT1020(rtcm->bin_to_binary_data(rtcm->hex_to_bin("FFFFFFFFFFF")), gnav_ephemeris_read, gnav_utc_model_read));
|
2017-08-14 03:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, MT1029)
|
2015-12-23 21:18:43 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
|
|
|
std::string s_test("UTF-8 проверка wörter");
|
|
|
|
unsigned int ref_id = 23;
|
|
|
|
double obs_time = 0;
|
|
|
|
Gps_Ephemeris gps_eph = Gps_Ephemeris();
|
2018-03-03 01:03:39 +00:00
|
|
|
std::string m1029 = rtcm->bin_to_hex(rtcm->binary_data_to_bin(rtcm->print_MT1029(ref_id, gps_eph, obs_time, s_test)));
|
2015-12-23 21:18:43 +00:00
|
|
|
std::string encoded_text = m1029.substr(24, 60);
|
2016-05-01 23:24:23 +00:00
|
|
|
std::string expected_encoded_text("5554462D3820D0BFD180D0BED0B2D0B5D180D0BAD0B02077C3B672746572");
|
2015-12-23 21:18:43 +00:00
|
|
|
EXPECT_EQ(0, expected_encoded_text.compare(encoded_text));
|
|
|
|
|
2016-05-01 23:24:23 +00:00
|
|
|
std::string characters_to_follow = m1029.substr(22, 2);
|
2015-12-23 21:18:43 +00:00
|
|
|
std::string expected_characters_to_follow("1E");
|
|
|
|
EXPECT_EQ(0, expected_characters_to_follow.compare(characters_to_follow));
|
|
|
|
}
|
2015-11-23 23:31:53 +00:00
|
|
|
|
2015-12-23 21:18:43 +00:00
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, MT1045)
|
2015-11-23 23:31:53 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2016-01-21 23:04:28 +00:00
|
|
|
bool expected_true = true;
|
2015-11-23 23:31:53 +00:00
|
|
|
|
|
|
|
Galileo_Ephemeris gal_eph = Galileo_Ephemeris();
|
|
|
|
Galileo_Ephemeris gal_eph_read = Galileo_Ephemeris();
|
|
|
|
|
|
|
|
gal_eph.i_satellite_PRN = 5;
|
|
|
|
gal_eph.OMEGA_dot_3 = 53.0 * OMEGA_dot_3_LSB;
|
|
|
|
gal_eph.E5a_DVS = true;
|
|
|
|
|
|
|
|
std::string tx_msg = rtcm->print_MT1045(gal_eph);
|
|
|
|
|
|
|
|
EXPECT_EQ(0, rtcm->read_MT1045(tx_msg, gal_eph_read));
|
2016-01-21 23:04:28 +00:00
|
|
|
EXPECT_EQ(expected_true, gal_eph_read.E5a_DVS);
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_DOUBLE_EQ(53.0 * OMEGA_dot_3_LSB, gal_eph_read.OMEGA_dot_3);
|
2017-08-18 11:42:27 +00:00
|
|
|
EXPECT_EQ(static_cast<unsigned int>(5), gal_eph_read.i_satellite_PRN);
|
2016-05-01 10:39:40 +00:00
|
|
|
EXPECT_EQ(1, rtcm->read_MT1045(rtcm->bin_to_binary_data(rtcm->hex_to_bin("FFFFFFFFFFF")), gal_eph_read));
|
2015-11-22 13:43:52 +00:00
|
|
|
}
|
|
|
|
|
2015-11-29 00:10:10 +00:00
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, MSMCell)
|
2015-12-05 10:27:15 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
|
|
|
Gps_Ephemeris gps_eph = Gps_Ephemeris();
|
|
|
|
Galileo_Ephemeris gal_eph = Galileo_Ephemeris();
|
2018-01-24 17:25:06 +00:00
|
|
|
//Glonass_Gnav_Ephemeris glo_gnav_eph = Glonass_Gnav_Ephemeris();
|
2015-12-05 10:27:15 +00:00
|
|
|
std::map<int, Gnss_Synchro> pseudoranges;
|
|
|
|
|
|
|
|
Gnss_Synchro gnss_synchro;
|
|
|
|
Gnss_Synchro gnss_synchro2;
|
|
|
|
Gnss_Synchro gnss_synchro3;
|
|
|
|
Gnss_Synchro gnss_synchro4;
|
|
|
|
Gnss_Synchro gnss_synchro5;
|
2017-08-14 03:42:24 +00:00
|
|
|
Gnss_Synchro gnss_synchro6;
|
2015-12-05 10:27:15 +00:00
|
|
|
|
|
|
|
gnss_synchro.PRN = 4;
|
|
|
|
gnss_synchro2.PRN = 8;
|
|
|
|
gnss_synchro3.PRN = 32;
|
|
|
|
gnss_synchro4.PRN = 10;
|
|
|
|
gnss_synchro5.PRN = 10;
|
2017-08-14 03:42:24 +00:00
|
|
|
gnss_synchro6.PRN = 10;
|
2015-12-05 10:27:15 +00:00
|
|
|
|
|
|
|
std::string gps = "G";
|
|
|
|
std::string gal = "E";
|
2017-08-14 03:42:24 +00:00
|
|
|
std::string glo = "R";
|
2015-12-05 10:27:15 +00:00
|
|
|
|
|
|
|
std::string c1 = "1C";
|
|
|
|
std::string s2 = "2S";
|
|
|
|
std::string x5 = "5X";
|
|
|
|
|
|
|
|
gnss_synchro.System = *gal.c_str();
|
|
|
|
gnss_synchro2.System = *gps.c_str();
|
|
|
|
gnss_synchro3.System = *gps.c_str();
|
|
|
|
gnss_synchro4.System = *gal.c_str();
|
|
|
|
gnss_synchro5.System = *gps.c_str();
|
2017-08-14 03:42:24 +00:00
|
|
|
gnss_synchro6.System = *glo.c_str();
|
2015-12-05 10:27:15 +00:00
|
|
|
|
2017-08-20 23:13:37 +00:00
|
|
|
std::memcpy((void*)gnss_synchro.Signal, x5.c_str(), 3);
|
|
|
|
std::memcpy((void*)gnss_synchro2.Signal, s2.c_str(), 3);
|
|
|
|
std::memcpy((void*)gnss_synchro3.Signal, c1.c_str(), 3);
|
|
|
|
std::memcpy((void*)gnss_synchro4.Signal, x5.c_str(), 3);
|
|
|
|
std::memcpy((void*)gnss_synchro5.Signal, c1.c_str(), 3);
|
|
|
|
std::memcpy((void*)gnss_synchro6.Signal, c1.c_str(), 3);
|
2015-12-05 10:27:15 +00:00
|
|
|
|
|
|
|
gnss_synchro.Pseudorange_m = 20000000.0;
|
|
|
|
gnss_synchro2.Pseudorange_m = 20001010.0;
|
|
|
|
gnss_synchro3.Pseudorange_m = 24002020.0;
|
|
|
|
gnss_synchro4.Pseudorange_m = 20003010.1;
|
|
|
|
gnss_synchro5.Pseudorange_m = 22003010.1;
|
2017-08-14 03:42:24 +00:00
|
|
|
gnss_synchro6.Pseudorange_m = 22003010.1;
|
2015-12-05 10:27:15 +00:00
|
|
|
|
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(1, gnss_synchro));
|
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(2, gnss_synchro2));
|
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(3, gnss_synchro3));
|
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(4, gnss_synchro4));
|
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(5, gnss_synchro5));
|
2017-08-14 03:42:24 +00:00
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(6, gnss_synchro5));
|
2015-12-05 10:27:15 +00:00
|
|
|
|
|
|
|
unsigned int ref_id = 1234;
|
|
|
|
unsigned int clock_steering_indicator = 0;
|
|
|
|
unsigned int external_clock_indicator = 0;
|
|
|
|
int smooth_int = 0;
|
|
|
|
bool divergence_free = false;
|
|
|
|
bool more_messages = false;
|
|
|
|
double obs_time = 25.0;
|
|
|
|
|
2015-12-05 12:32:45 +00:00
|
|
|
gps_eph.i_satellite_PRN = gnss_synchro2.PRN;
|
|
|
|
gal_eph.i_satellite_PRN = gnss_synchro.PRN;
|
2018-01-24 17:25:06 +00:00
|
|
|
//glo_gnav_eph.i_satellite_PRN = gnss_synchro.PRN;
|
2015-12-05 10:27:15 +00:00
|
|
|
|
|
|
|
std::string MSM1 = rtcm->print_MSM_1(gps_eph,
|
2018-03-03 01:03:39 +00:00
|
|
|
{},
|
|
|
|
gal_eph,
|
|
|
|
{},
|
|
|
|
obs_time,
|
|
|
|
pseudoranges,
|
|
|
|
ref_id,
|
|
|
|
clock_steering_indicator,
|
|
|
|
external_clock_indicator,
|
|
|
|
smooth_int,
|
|
|
|
divergence_free,
|
|
|
|
more_messages);
|
2015-12-05 10:27:15 +00:00
|
|
|
|
2016-04-30 13:20:56 +00:00
|
|
|
std::string MSM1_bin = rtcm->binary_data_to_bin(MSM1);
|
2015-12-05 10:27:15 +00:00
|
|
|
unsigned int Nsat = 4;
|
|
|
|
unsigned int Nsig = 3;
|
|
|
|
unsigned int size_header = 14;
|
|
|
|
unsigned int size_msg_length = 10;
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_EQ(0, MSM1_bin.substr(size_header + size_msg_length + 169, Nsat * Nsig).compare("001010101100")); // check cell mask
|
2015-12-05 10:27:15 +00:00
|
|
|
|
|
|
|
std::map<int, Gnss_Synchro> pseudoranges2;
|
2017-08-14 03:42:24 +00:00
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(1, gnss_synchro6));
|
2015-12-05 10:27:15 +00:00
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(1, gnss_synchro5));
|
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(2, gnss_synchro4));
|
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(3, gnss_synchro3));
|
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(4, gnss_synchro2));
|
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(5, gnss_synchro));
|
2017-08-14 03:42:24 +00:00
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(6, gnss_synchro));
|
2015-12-05 10:27:15 +00:00
|
|
|
std::string MSM1_2 = rtcm->print_MSM_1(gps_eph,
|
2018-03-03 01:03:39 +00:00
|
|
|
{},
|
|
|
|
gal_eph,
|
|
|
|
{},
|
|
|
|
obs_time,
|
|
|
|
pseudoranges2,
|
|
|
|
ref_id,
|
|
|
|
clock_steering_indicator,
|
|
|
|
external_clock_indicator,
|
|
|
|
smooth_int,
|
|
|
|
divergence_free,
|
|
|
|
more_messages);
|
2016-04-30 13:20:56 +00:00
|
|
|
std::string MSM1_bin_2 = rtcm->binary_data_to_bin(MSM1_2);
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_EQ(0, MSM1_bin_2.substr(size_header + size_msg_length + 169, Nsat * Nsig).compare("001010001100")); // check cell mask
|
2015-12-05 10:27:15 +00:00
|
|
|
|
2017-08-14 03:42:24 +00:00
|
|
|
Gnss_Synchro gnss_synchro7;
|
|
|
|
gnss_synchro7.PRN = 10;
|
|
|
|
gnss_synchro7.System = *gps.c_str();
|
2017-08-20 23:13:37 +00:00
|
|
|
std::memcpy((void*)gnss_synchro7.Signal, s2.c_str(), 3);
|
2017-08-14 03:42:24 +00:00
|
|
|
gnss_synchro7.Pseudorange_m = 24000000.0;
|
2015-12-05 10:27:15 +00:00
|
|
|
|
|
|
|
std::map<int, Gnss_Synchro> pseudoranges3;
|
|
|
|
pseudoranges3.insert(std::pair<int, Gnss_Synchro>(1, gnss_synchro));
|
|
|
|
pseudoranges3.insert(std::pair<int, Gnss_Synchro>(2, gnss_synchro2));
|
2017-08-14 03:42:24 +00:00
|
|
|
pseudoranges3.insert(std::pair<int, Gnss_Synchro>(3, gnss_synchro7));
|
2015-12-05 10:27:15 +00:00
|
|
|
pseudoranges3.insert(std::pair<int, Gnss_Synchro>(4, gnss_synchro4));
|
|
|
|
pseudoranges3.insert(std::pair<int, Gnss_Synchro>(5, gnss_synchro5));
|
|
|
|
|
|
|
|
std::string MSM1_3 = rtcm->print_MSM_1(gps_eph,
|
2018-03-03 01:03:39 +00:00
|
|
|
{},
|
|
|
|
gal_eph,
|
|
|
|
{},
|
|
|
|
obs_time,
|
|
|
|
pseudoranges3,
|
|
|
|
ref_id,
|
|
|
|
clock_steering_indicator,
|
|
|
|
external_clock_indicator,
|
|
|
|
smooth_int,
|
|
|
|
divergence_free,
|
|
|
|
more_messages);
|
2016-04-30 13:20:56 +00:00
|
|
|
std::string MSM1_bin_3 = rtcm->binary_data_to_bin(MSM1_3);
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_EQ(0, MSM1_bin_3.substr(size_header + size_msg_length + 169, (Nsat - 1) * Nsig).compare("001010111")); // check cell mask
|
2015-12-05 10:27:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, MSM1)
|
2015-11-29 00:10:10 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2016-01-21 23:04:28 +00:00
|
|
|
bool expected_true = true;
|
2015-11-29 00:10:10 +00:00
|
|
|
Gps_Ephemeris gps_eph = Gps_Ephemeris();
|
|
|
|
std::map<int, Gnss_Synchro> pseudoranges;
|
|
|
|
|
|
|
|
Gnss_Synchro gnss_synchro;
|
|
|
|
Gnss_Synchro gnss_synchro2;
|
|
|
|
Gnss_Synchro gnss_synchro3;
|
2015-12-04 12:06:05 +00:00
|
|
|
Gnss_Synchro gnss_synchro4;
|
2015-11-29 00:10:10 +00:00
|
|
|
|
|
|
|
gnss_synchro.PRN = 2;
|
|
|
|
gnss_synchro2.PRN = 4;
|
|
|
|
gnss_synchro3.PRN = 32;
|
2015-12-04 12:06:05 +00:00
|
|
|
gnss_synchro4.PRN = 4;
|
2015-11-29 00:10:10 +00:00
|
|
|
|
|
|
|
std::string sys = "G";
|
|
|
|
|
|
|
|
std::string sig = "1C";
|
|
|
|
std::string sig2 = "2S";
|
|
|
|
|
|
|
|
gnss_synchro.System = *sys.c_str();
|
|
|
|
gnss_synchro2.System = *sys.c_str();
|
|
|
|
gnss_synchro3.System = *sys.c_str();
|
2015-12-04 12:06:05 +00:00
|
|
|
gnss_synchro4.System = *sys.c_str();
|
2015-11-29 00:10:10 +00:00
|
|
|
|
2017-08-19 18:05:52 +00:00
|
|
|
std::memcpy(static_cast<void*>(gnss_synchro.Signal), sig.c_str(), 3);
|
|
|
|
std::memcpy(static_cast<void*>(gnss_synchro2.Signal), sig.c_str(), 3);
|
|
|
|
std::memcpy(static_cast<void*>(gnss_synchro3.Signal), sig2.c_str(), 3);
|
|
|
|
std::memcpy(static_cast<void*>(gnss_synchro4.Signal), sig2.c_str(), 3);
|
2015-11-29 00:10:10 +00:00
|
|
|
|
|
|
|
gnss_synchro.Pseudorange_m = 20000000.0;
|
2015-12-04 12:06:05 +00:00
|
|
|
gnss_synchro2.Pseudorange_m = 20001010.0;
|
|
|
|
gnss_synchro3.Pseudorange_m = 24002020.0;
|
|
|
|
gnss_synchro4.Pseudorange_m = 20003010.1;
|
2015-11-29 00:10:10 +00:00
|
|
|
|
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(1, gnss_synchro));
|
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(2, gnss_synchro2));
|
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(3, gnss_synchro3));
|
2015-12-04 12:06:05 +00:00
|
|
|
pseudoranges.insert(std::pair<int, Gnss_Synchro>(4, gnss_synchro4));
|
2015-11-29 00:10:10 +00:00
|
|
|
|
2016-05-06 19:00:08 +00:00
|
|
|
unsigned short ref_id = 1234;
|
2015-11-29 00:10:10 +00:00
|
|
|
unsigned int clock_steering_indicator = 0;
|
|
|
|
unsigned int external_clock_indicator = 0;
|
|
|
|
int smooth_int = 0;
|
|
|
|
bool divergence_free = false;
|
|
|
|
bool more_messages = false;
|
|
|
|
double obs_time = 25.0;
|
|
|
|
|
|
|
|
gps_eph.i_satellite_PRN = gnss_synchro.PRN;
|
|
|
|
|
|
|
|
std::string MSM1 = rtcm->print_MSM_1(gps_eph,
|
2018-03-03 01:03:39 +00:00
|
|
|
{}, {}, {},
|
|
|
|
obs_time,
|
|
|
|
pseudoranges,
|
|
|
|
ref_id,
|
|
|
|
clock_steering_indicator,
|
|
|
|
external_clock_indicator,
|
|
|
|
smooth_int,
|
|
|
|
divergence_free,
|
|
|
|
more_messages);
|
2015-11-29 00:10:10 +00:00
|
|
|
|
2016-01-21 23:04:28 +00:00
|
|
|
EXPECT_EQ(expected_true, rtcm->check_CRC(MSM1));
|
2015-12-04 12:06:05 +00:00
|
|
|
|
2016-04-30 13:20:56 +00:00
|
|
|
std::string MSM1_bin = rtcm->binary_data_to_bin(MSM1);
|
2015-12-04 12:06:05 +00:00
|
|
|
unsigned int Nsat = 3;
|
|
|
|
unsigned int Nsig = 2;
|
|
|
|
unsigned int size_header = 14;
|
|
|
|
unsigned int size_crc = 24;
|
|
|
|
unsigned int size_msg_length = 10;
|
|
|
|
unsigned int upper_bound = 169 + Nsat * 10 + 43 * Nsig;
|
|
|
|
unsigned int data_size = MSM1_bin.length() - size_header - size_msg_length - size_crc;
|
2016-01-21 23:04:28 +00:00
|
|
|
EXPECT_EQ(expected_true, upper_bound >= data_size);
|
2015-12-04 12:06:05 +00:00
|
|
|
EXPECT_EQ(0, MSM1_bin.substr(0, size_header).compare("11010011000000"));
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_EQ(ref_id, rtcm->bin_to_uint(MSM1_bin.substr(size_header + size_msg_length + 12, 12)));
|
|
|
|
EXPECT_EQ(0, MSM1_bin.substr(size_header + size_msg_length + 169, Nsat * Nsig).compare("101101")); // check cell mask
|
2015-12-04 12:06:05 +00:00
|
|
|
|
|
|
|
double meters_to_miliseconds = GPS_C_m_s * 0.001;
|
|
|
|
unsigned int rough_range_1 = static_cast<unsigned int>(std::floor(std::round(gnss_synchro.Pseudorange_m / meters_to_miliseconds / TWO_N10)) + 0.5) & 0x3FFu;
|
|
|
|
unsigned int rough_range_2 = static_cast<unsigned int>(std::floor(std::round(gnss_synchro2.Pseudorange_m / meters_to_miliseconds / TWO_N10)) + 0.5) & 0x3FFu;
|
|
|
|
unsigned int rough_range_4 = static_cast<unsigned int>(std::floor(std::round(gnss_synchro3.Pseudorange_m / meters_to_miliseconds / TWO_N10)) + 0.5) & 0x3FFu;
|
2018-03-03 01:03:39 +00:00
|
|
|
unsigned int read_pseudorange_1 = rtcm->bin_to_uint(MSM1_bin.substr(size_header + size_msg_length + 169 + Nsat * Nsig, 10));
|
|
|
|
unsigned int read_pseudorange_2 = rtcm->bin_to_uint(MSM1_bin.substr(size_header + size_msg_length + 169 + Nsat * Nsig + 10, 10));
|
|
|
|
unsigned int read_pseudorange_4 = rtcm->bin_to_uint(MSM1_bin.substr(size_header + size_msg_length + 169 + Nsat * Nsig + 20, 10));
|
2015-12-04 12:06:05 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(rough_range_1, read_pseudorange_1);
|
|
|
|
EXPECT_EQ(rough_range_2, read_pseudorange_2);
|
|
|
|
EXPECT_EQ(rough_range_4, read_pseudorange_4);
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
int psrng4_s = static_cast<int>(std::round((gnss_synchro3.Pseudorange_m - std::round(gnss_synchro3.Pseudorange_m / meters_to_miliseconds / TWO_N10) * meters_to_miliseconds * TWO_N10) / meters_to_miliseconds / TWO_N24));
|
|
|
|
int read_psrng4_s = rtcm->bin_to_int(MSM1_bin.substr(size_header + size_msg_length + 169 + (Nsat * Nsig) + 30 + 15 * 3, 15));
|
2015-12-04 12:06:05 +00:00
|
|
|
EXPECT_EQ(psrng4_s, read_psrng4_s);
|
2015-12-05 10:27:15 +00:00
|
|
|
|
|
|
|
std::map<int, Gnss_Synchro> pseudoranges2;
|
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(1, gnss_synchro4));
|
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(2, gnss_synchro3));
|
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(3, gnss_synchro2));
|
|
|
|
pseudoranges2.insert(std::pair<int, Gnss_Synchro>(4, gnss_synchro));
|
|
|
|
std::string MSM1_2 = rtcm->print_MSM_1(gps_eph,
|
2018-03-03 01:03:39 +00:00
|
|
|
{}, {}, {},
|
|
|
|
obs_time,
|
|
|
|
pseudoranges2,
|
|
|
|
ref_id,
|
|
|
|
clock_steering_indicator,
|
|
|
|
external_clock_indicator,
|
|
|
|
smooth_int,
|
|
|
|
divergence_free,
|
|
|
|
more_messages);
|
2016-04-30 13:20:56 +00:00
|
|
|
std::string MSM1_bin2 = rtcm->binary_data_to_bin(MSM1_2);
|
2018-03-03 01:03:39 +00:00
|
|
|
int read_psrng4_s_2 = rtcm->bin_to_int(MSM1_bin2.substr(size_header + size_msg_length + 169 + (Nsat * Nsig) + 30 + 15 * 3, 15));
|
2015-12-05 10:27:15 +00:00
|
|
|
EXPECT_EQ(psrng4_s, read_psrng4_s_2);
|
2015-11-29 00:10:10 +00:00
|
|
|
}
|
|
|
|
|
2015-12-15 14:04:58 +00:00
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, InstantiateServer)
|
2015-12-15 14:04:58 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
|
|
|
rtcm->run_server();
|
|
|
|
std::string msg("Hello");
|
|
|
|
rtcm->send_message(msg);
|
|
|
|
std::string test3 = "ff";
|
|
|
|
std::string test3_bin = rtcm->hex_to_bin(test3);
|
|
|
|
EXPECT_EQ(0, test3_bin.compare("11111111"));
|
|
|
|
rtcm->stop_server();
|
|
|
|
std::string test6 = "0011";
|
|
|
|
std::string test6_hex = rtcm->bin_to_hex(test6);
|
|
|
|
EXPECT_EQ(0, test6_hex.compare("3"));
|
2018-08-10 19:16:10 +00:00
|
|
|
uint64_t expected1 = 42;
|
2015-12-15 14:04:58 +00:00
|
|
|
EXPECT_EQ(expected1, rtcm->bin_to_uint("00101010"));
|
|
|
|
rtcm->run_server();
|
|
|
|
std::string test4_bin = rtcm->hex_to_bin(test3);
|
2016-05-01 10:39:40 +00:00
|
|
|
std::string s = rtcm->bin_to_binary_data(test4_bin);
|
2015-12-15 14:04:58 +00:00
|
|
|
rtcm->send_message(s);
|
|
|
|
rtcm->stop_server();
|
|
|
|
EXPECT_EQ(0, test4_bin.compare("11111111"));
|
|
|
|
}
|
|
|
|
|
2015-12-23 21:18:43 +00:00
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmTest, InstantiateServerWithoutClosing)
|
2015-12-15 14:04:58 +00:00
|
|
|
{
|
|
|
|
auto rtcm = std::make_shared<Rtcm>();
|
2015-12-23 21:18:43 +00:00
|
|
|
rtcm->run_server();
|
|
|
|
std::string msg("Hello");
|
|
|
|
rtcm->send_message(msg);
|
2015-12-15 14:04:58 +00:00
|
|
|
std::string test3 = "ff";
|
|
|
|
std::string test3_bin = rtcm->hex_to_bin(test3);
|
|
|
|
EXPECT_EQ(0, test3_bin.compare("11111111"));
|
2015-12-23 21:18:43 +00:00
|
|
|
}
|