mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	working on the RTCM printer
This commit is contained in:
		| @@ -34,18 +34,11 @@ | ||||
| #include "rtcm_printer.h" | ||||
| #include <fcntl.h>    // for O_RDWR | ||||
| #include <termios.h>  // for tcgetattr | ||||
| #include <algorithm>  // for std::reverse | ||||
| #include <sstream>    // for std::stringstream | ||||
| #include <boost/algorithm/string.hpp>  // for to_upper_copy | ||||
| #include <boost/date_time/posix_time/posix_time.hpp> | ||||
| #include <boost/dynamic_bitset.hpp> | ||||
| #include <gflags/gflags.h> | ||||
| #include <glog/logging.h> | ||||
|  | ||||
|  | ||||
| using google::LogMessage; | ||||
|  | ||||
| //DEFINE_string(RTCM_version, "3.2", "Specifies the RTCM Version"); | ||||
|  | ||||
| Rtcm_Printer::Rtcm_Printer(std::string filename, bool flag_rtcm_tty_port, std::string rtcm_dump_devname) | ||||
| { | ||||
| @@ -69,9 +62,7 @@ Rtcm_Printer::Rtcm_Printer(std::string filename, bool flag_rtcm_tty_port, std::s | ||||
|         { | ||||
|             rtcm_dev_descriptor = -1; | ||||
|         } | ||||
|     Rtcm_Printer::reset_data_fields(); | ||||
|     preamble = std::bitset<8>("11010011"); | ||||
|     reserved_field = std::bitset<6>("000000"); | ||||
|     rtcm = std::make_shared<Rtcm>(); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -93,6 +84,27 @@ Rtcm_Printer::~Rtcm_Printer() | ||||
| } | ||||
|  | ||||
|  | ||||
| bool Rtcm_Printer::Print_Rtcm_M1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map<int, Gnss_Synchro> & pseudoranges) | ||||
| { | ||||
|     std::string m1001 = rtcm->print_M1001( gps_eph, obs_time, pseudoranges); | ||||
|     Rtcm_Printer::Print_Message(m1001); | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| bool Rtcm_Printer::Print_Rtcm_M1019(const Gps_Ephemeris & gps_eph) | ||||
| { | ||||
|     std::string m1019 = rtcm->print_M1019(gps_eph); | ||||
|     Rtcm_Printer::Print_Message(m1019); | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| bool Rtcm_Printer::Print_Rtcm_M1045(const Galileo_Ephemeris & gal_eph) | ||||
| { | ||||
|     std::string m1045 = rtcm->print_M1045(gal_eph); | ||||
|     Rtcm_Printer::Print_Message(m1045); | ||||
|     return true; | ||||
| } | ||||
|  | ||||
|  | ||||
| int Rtcm_Printer::init_serial(std::string serial_device) | ||||
| { | ||||
| @@ -140,255 +152,39 @@ void Rtcm_Printer::close_serial() | ||||
|         } | ||||
| } | ||||
|  | ||||
| void Rtcm_Printer::reset_data_fields() | ||||
|  | ||||
|  | ||||
| bool Rtcm_Printer::Print_Message(std::string message) | ||||
| { | ||||
|     //DF001.reset(); | ||||
|     DF002.reset(); | ||||
|     DF003.reset(); | ||||
|     DF004.reset(); | ||||
|     DF005.reset(); | ||||
|     DF006.reset(); | ||||
|     DF007.reset(); | ||||
|     DF008.reset(); | ||||
|     DF009.reset(); | ||||
|     DF010.reset(); | ||||
|     DF011.reset(); | ||||
|     DF012.reset(); | ||||
|     DF013.reset(); | ||||
|     DF014.reset(); | ||||
|     DF015.reset(); | ||||
|     try | ||||
|     { | ||||
|             rtcm_file_descriptor << message << std::endl; | ||||
|  | ||||
|     // Contents of GPS Satellite Ephemeris Data, Message Type 1019 | ||||
|     DF071.reset(); | ||||
|     DF076.reset(); | ||||
|     DF077.reset(); | ||||
|     DF078.reset(); | ||||
|     DF079.reset(); | ||||
|     DF081.reset(); | ||||
|     DF082.reset(); | ||||
|     DF083.reset(); | ||||
|     DF084.reset(); | ||||
|     DF085.reset(); | ||||
|     DF086.reset(); | ||||
|     DF087.reset(); | ||||
|     } | ||||
|     catch(std::exception ex) | ||||
|     { | ||||
|             DLOG(INFO) << "RTCM printer can not write on output file" << rtcm_filename.c_str(); | ||||
|     } | ||||
|  | ||||
|     DF088.reset(); | ||||
|     DF089.reset(); | ||||
|     DF090.reset(); | ||||
|     DF091.reset(); | ||||
|     DF092.reset(); | ||||
|     DF093.reset(); | ||||
|     DF094.reset(); | ||||
|     DF095.reset(); | ||||
|     DF096.reset(); | ||||
|     DF097.reset(); | ||||
|     DF098.reset(); | ||||
|     DF099.reset(); | ||||
|     DF100.reset(); | ||||
|     DF101.reset(); | ||||
|     DF102.reset(); | ||||
|     DF103.reset(); | ||||
|     DF137.reset(); | ||||
|  | ||||
|     // Contents of Galileo F/NAV Satellite Ephemeris Data, Message Type 1045 | ||||
|     DF252.reset(); | ||||
|     DF289.reset(); | ||||
|     DF290.reset(); | ||||
|     DF291.reset(); | ||||
|     DF292.reset(); | ||||
|     DF293.reset(); | ||||
|     DF294.reset(); | ||||
|     DF295.reset(); | ||||
|     DF296.reset(); | ||||
|     DF297.reset(); | ||||
|     DF298.reset(); | ||||
|     DF299.reset(); | ||||
|     DF300.reset(); | ||||
|     DF301.reset(); | ||||
|     DF302.reset(); | ||||
|     DF303.reset(); | ||||
|     DF304.reset(); | ||||
|     DF305.reset(); | ||||
|     DF306.reset(); | ||||
|     DF307.reset(); | ||||
|     DF308.reset(); | ||||
|     DF309.reset(); | ||||
|     DF310.reset(); | ||||
|     DF311.reset(); | ||||
|     DF312.reset(); | ||||
|     DF314.reset(); | ||||
|     DF315.reset(); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| /* Stationary Antenna Reference Point, No Height Information | ||||
|  * Reference Station Id = 2003 | ||||
|    GPS Service supported, but not GLONASS or Galileo | ||||
|    ARP ECEF-X = 1114104.5999 meters | ||||
|    ARP ECEF-Y = -4850729.7108 meters | ||||
|    ARP ECEF-Z = 3975521.4643 meters | ||||
|    Expected output: D3 00 13 3E D7 D3 02 02 98 0E DE EF 34 B4 BD 62 | ||||
|                     AC 09 41 98 6F 33 36 0B 98 | ||||
|  */ | ||||
| std::bitset<152> Rtcm_Printer::get_M1005_test () | ||||
| { | ||||
|     unsigned int m1005 = 1005; | ||||
|     unsigned int reference_station_id = 2003; // Max: 4095 | ||||
|     long long int ECEF_X = 11141045999;       // Resolution 0.0001 m | ||||
|     long long int ECEF_Y = -48507297108;      // Resolution 0.0001 m | ||||
|     long long int ECEF_Z = 39755214643;       // Resolution 0.0001 m | ||||
|     unsigned int itrf_realization_year = 0;   // Reserved | ||||
|     std::bitset<1> DF001; | ||||
|  | ||||
|     DF002 = std::bitset<12>(m1005); | ||||
|     DF003 = std::bitset<12>(reference_station_id); | ||||
|     DF021 = std::bitset<6>(itrf_realization_year); | ||||
|     DF022 = std::bitset<1>("1");          // GPS | ||||
|     DF023 = std::bitset<1>("0");          // Glonass | ||||
|     DF024 = std::bitset<1>("0");          // Galileo | ||||
|     DF141 = std::bitset<1>("0");          // 0: Real, physical reference station | ||||
|     DF001 = std::bitset<1>("0");          // Reserved, set to 0 | ||||
|     DF025 = std::bitset<38>(ECEF_X);      // ECEF-X in 0.0001 m | ||||
|     DF142 = std::bitset<1>("0");          // Single Receiver Oscillator Indicator | ||||
|     DF026 = std::bitset<38>(ECEF_Y);      // ECEF-Y in 0.0001 m | ||||
|     DF364 = std::bitset<2>("00");         // Quarter Cycle Indicator | ||||
|     DF027 = std::bitset<38>(ECEF_Z);      // ECEF-Z in 0.0001 m | ||||
|  | ||||
|     std::string message = DF002.to_string() + | ||||
|             DF003.to_string() + | ||||
|             DF021.to_string() + | ||||
|             DF022.to_string() + | ||||
|             DF023.to_string() + | ||||
|             DF024.to_string() + | ||||
|             DF141.to_string() + | ||||
|             DF025.to_string() + | ||||
|             DF142.to_string() + | ||||
|             DF001.to_string() + | ||||
|             DF026.to_string() + | ||||
|             DF364.to_string() + | ||||
|             DF027.to_string() ; | ||||
|  | ||||
|     std::bitset<152> test_msg(message); | ||||
|     return test_msg; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| std::string Rtcm_Printer::print_M1005_test () | ||||
| { | ||||
|     std::bitset<152> m1005 = get_M1005_test(); | ||||
|     unsigned int msg_length_bits = m1005.to_string().length(); | ||||
|     unsigned int msg_length_bytes = std::ceil(static_cast<float>(msg_length_bits) / 8.0); | ||||
|     message_length = std::bitset<10>(msg_length_bytes); | ||||
|     unsigned int zeros_to_fill = 8*msg_length_bytes -  msg_length_bits; | ||||
|     std::string b(zeros_to_fill, '0'); | ||||
|     std::string msg_content = m1005.to_string() + b; | ||||
|     std::string msg_without_crc = preamble.to_string() + | ||||
|             reserved_field.to_string() + | ||||
|             message_length.to_string() + | ||||
|             msg_content; | ||||
|     return Rtcm_Printer::add_CRC(msg_without_crc); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| std::bitset<122> Rtcm_Printer::get_M1001() | ||||
| { | ||||
|     unsigned int m1001 = 1001; | ||||
|     unsigned int reference_station_id = 1234; // Max: 4095 | ||||
|     DF002 = std::bitset<12>(m1001); | ||||
|     DF003 = std::bitset<12>(reference_station_id); | ||||
|     //DF004 = std::bitset<30> | ||||
|     //DF005 = std::bitset<1> | ||||
|     //DF006 = std::bitset<5> | ||||
|     DF007 = std::bitset<1>("0"); | ||||
|     //DF008 = std::bitset<3> | ||||
|     std::bitset<122> fake_msg; | ||||
|     fake_msg.reset(); | ||||
|     return fake_msg; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void Rtcm_Printer::print_M1001 () | ||||
| { | ||||
|     std::bitset<122> m1001 = get_M1001(); | ||||
|     unsigned int msg_length_bits = m1001.to_string().length(); | ||||
|     unsigned int msg_length_bytes = std::ceil(static_cast<float>(msg_length_bits) / 8.0); | ||||
|     message_length = std::bitset<10>(msg_length_bytes); | ||||
|     unsigned int zeros_to_fill = 8*msg_length_bytes -  msg_length_bits; | ||||
|     std::string b(zeros_to_fill, '0'); | ||||
|     message_length = std::bitset<10>(static_cast<int>(msg_length_bytes)); | ||||
|     std::string msg_content = m1001.to_string() + b; | ||||
|     std::string msg_without_crc = preamble.to_string() + | ||||
|             reserved_field.to_string() + | ||||
|             message_length.to_string() + | ||||
|             msg_content; | ||||
|     std::string message = Rtcm_Printer::add_CRC(msg_without_crc); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| std::bitset<138> Rtcm_Printer::get_M1002 () | ||||
| { | ||||
|     std::bitset<138> fake_msg; | ||||
|     fake_msg.reset(); | ||||
|     return fake_msg; | ||||
| } | ||||
|  | ||||
| std::bitset<488> Rtcm_Printer::get_M1019 () | ||||
| { | ||||
|     std::bitset<488> fake_msg; | ||||
|         fake_msg.reset(); | ||||
|         return fake_msg; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| std::bitset<496> Rtcm_Printer::get_M1045 () | ||||
| { | ||||
|     std::bitset<496> fake_msg; | ||||
|     fake_msg.reset(); | ||||
|     return fake_msg; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| std::string Rtcm_Printer::add_CRC (const std::string& message_without_crc) | ||||
| { | ||||
|     // ******  Computes Qualcomm CRC-24Q ****** | ||||
|     // 1) Converts the string to a vector of unsigned char: | ||||
|     boost::dynamic_bitset<unsigned char> frame_bits(message_without_crc); | ||||
|     std::vector<unsigned char> bytes; | ||||
|     boost::to_block_range(frame_bits, std::back_inserter(bytes)); | ||||
|     std::reverse(bytes.begin(),bytes.end()); | ||||
|  | ||||
|     // 2) Computes CRC | ||||
|     CRC_RTCM.process_bytes(bytes.data(), bytes.size()); | ||||
|     crc_frame = std::bitset<24>(CRC_RTCM.checksum()); | ||||
|  | ||||
|     // 3) Builds the complete message | ||||
|     std::string complete_message = message_without_crc + crc_frame.to_string(); | ||||
|     return bin_to_hex(complete_message); | ||||
| } | ||||
|  | ||||
|  | ||||
| std::string  Rtcm_Printer::bin_to_hex(const std::string& s) | ||||
| { | ||||
|     std::string s_aux; | ||||
|     std::stringstream ss; | ||||
|     for(int i = 0; i < s.length() - 1; i = i + 32) | ||||
|     //write to serial device | ||||
|     if (rtcm_dev_descriptor!=-1) | ||||
|         { | ||||
|             s_aux.assign(s, i, 32); | ||||
|             std::bitset<32> bs(s_aux); | ||||
|             unsigned n = bs.to_ulong(); | ||||
|             ss << std::hex << n; | ||||
|             try | ||||
|             { | ||||
|                     int n_bytes_written; | ||||
|                     n_bytes_written = write(rtcm_dev_descriptor, message.c_str(), message.length()); | ||||
|             } | ||||
|             catch(std::exception ex) | ||||
|             { | ||||
|                     DLOG(INFO) << "RTCM printer can not write on serial device" << rtcm_filename.c_str();; | ||||
|             } | ||||
|         } | ||||
|     //return ss.str(); | ||||
|     return boost::to_upper_copy(ss.str()); | ||||
|     return true; | ||||
| } | ||||
|  | ||||
|  | ||||
| std::string Rtcm_Printer::print_M1005_test() | ||||
| { | ||||
|     std::string test = rtcm->print_M1005_test(); | ||||
|     return test; | ||||
| } | ||||
|   | ||||
| @@ -34,13 +34,9 @@ | ||||
| #ifndef GNSS_SDR_RTCM_PRINTER_H_ | ||||
| #define GNSS_SDR_RTCM_PRINTER_H_ | ||||
|  | ||||
| #include <bitset>   // std::bitset | ||||
| #include <fstream>  // std::ofstream | ||||
| #include <iostream> // std::cout | ||||
| #include <string>   // std::string | ||||
| #include <vector> | ||||
| #include <boost/crc.hpp> | ||||
|  | ||||
| #include "rtcm.h" | ||||
|  | ||||
| /*! | ||||
|  * \brief This class provides a implementation of a subset of the RTCM Standard 10403.2 messages | ||||
| @@ -53,170 +49,26 @@ public: | ||||
|      */ | ||||
|     Rtcm_Printer(std::string filename, bool flag_rtcm_tty_port, std::string rtcm_dump_filename); | ||||
|  | ||||
|     /*! | ||||
|      * \brief Print RTCM 3.2 messages to the initialized device | ||||
|      */ | ||||
|     //bool Print_Nmea_Line(gps_l1_ca_ls_pvt* position, bool print_average_values); | ||||
|  | ||||
|     /*! | ||||
|      * \brief Default destructor. | ||||
|      */ | ||||
|     ~Rtcm_Printer(); | ||||
|  | ||||
|     void print_M1001(); | ||||
|     std::string print_M1005_test(); | ||||
|     bool Print_Rtcm_M1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map<int, Gnss_Synchro> & pseudoranges); | ||||
|     bool Print_Rtcm_M1019(const Gps_Ephemeris & gps_eph); //<! GPS Ephemeris, should be broadcast in the event that the IODC does not match the IODE, and every 2 minutes. | ||||
|     bool Print_Rtcm_M1045(const Galileo_Ephemeris & gal_eph); //<! Galileo Ephemeris, should be broadcast every 2 minutes | ||||
|  | ||||
|     std::string print_M1005_test(); //<!  For testing purposes | ||||
|  | ||||
| private: | ||||
|     std::string rtcm_filename; // String with the RTCM log filename | ||||
|     std::ofstream rtcm_file_descriptor; // Output file stream for RTCM log file | ||||
|     std::string rtcm_devname; | ||||
|     int rtcm_dev_descriptor; // RTCM serial device descriptor (i.e. COM port) | ||||
|     //gps_l1_ca_ls_pvt* d_PVT_data; | ||||
|     int init_serial (std::string serial_device); //serial port control | ||||
|     void close_serial (); | ||||
|  | ||||
|     //std::bitset<8> DF001; | ||||
|     std::bitset<12> DF002; | ||||
|     std::bitset<12> DF003; | ||||
|     std::bitset<30> DF004; | ||||
|     std::bitset<1> DF005; | ||||
|     std::bitset<5> DF006; | ||||
|     std::bitset<1> DF007; | ||||
|     std::bitset<3> DF008; | ||||
|     std::bitset<6> DF009; | ||||
|     std::bitset<1> DF010; | ||||
|     std::bitset<24> DF011; | ||||
|     std::bitset<20> DF012; | ||||
|     std::bitset<7> DF013; | ||||
|     std::bitset<8> DF014; | ||||
|     std::bitset<8> DF015; | ||||
|  | ||||
|  | ||||
|     std::bitset<6> DF021; | ||||
|     std::bitset<1> DF022; | ||||
|     std::bitset<1> DF023; | ||||
|     std::bitset<1> DF024; | ||||
|     std::bitset<38> DF025; | ||||
|     std::bitset<38> DF026; | ||||
|     std::bitset<38> DF027; | ||||
|  | ||||
|     // Contents of GPS Satellite Ephemeris Data, Message Type 1019 | ||||
|     std::bitset<8> DF071; | ||||
|     std::bitset<10> DF076; | ||||
|     std::bitset<4> DF077; | ||||
|     std::bitset<2> DF078; | ||||
|     std::bitset<14> DF079; | ||||
|     std::bitset<16> DF081; | ||||
|     std::bitset<8> DF082; | ||||
|     std::bitset<16> DF083; | ||||
|     std::bitset<22> DF084; | ||||
|     std::bitset<10> DF085; | ||||
|     std::bitset<16> DF086; | ||||
|     std::bitset<16> DF087; | ||||
|  | ||||
|     std::bitset<32> DF088; | ||||
|     std::bitset<16> DF089; | ||||
|     std::bitset<32> DF090; | ||||
|     std::bitset<16> DF091; | ||||
|     std::bitset<32> DF092; | ||||
|     std::bitset<16> DF093; | ||||
|     std::bitset<16> DF094; | ||||
|     std::bitset<32> DF095; | ||||
|     std::bitset<16> DF096; | ||||
|     std::bitset<32> DF097; | ||||
|     std::bitset<16> DF098; | ||||
|     std::bitset<32> DF099; | ||||
|     std::bitset<24> DF100; | ||||
|     std::bitset<8> DF101; | ||||
|     std::bitset<6> DF102; | ||||
|     std::bitset<1> DF103; | ||||
|     std::bitset<1> DF137; | ||||
|  | ||||
|  | ||||
|     std::bitset<1> DF141; | ||||
|     std::bitset<1> DF142; | ||||
|  | ||||
|     // Contents of Galileo F/NAV Satellite Ephemeris Data, Message Type 1045 | ||||
|     std::bitset<6> DF252; | ||||
|     std::bitset<12> DF289; | ||||
|     std::bitset<10> DF290; | ||||
|     std::bitset<8> DF291; | ||||
|     std::bitset<14> DF292; | ||||
|     std::bitset<14> DF293; | ||||
|     std::bitset<6> DF294; | ||||
|     std::bitset<21> DF295; | ||||
|     std::bitset<31> DF296; | ||||
|     std::bitset<16> DF297; | ||||
|     std::bitset<32> DF298; | ||||
|     std::bitset<14> DF299; | ||||
|     std::bitset<16> DF300; | ||||
|     std::bitset<32> DF301; | ||||
|     std::bitset<16> DF302; | ||||
|     std::bitset<32> DF303; | ||||
|     std::bitset<14> DF304; | ||||
|     std::bitset<16> DF305; | ||||
|     std::bitset<32> DF306; | ||||
|     std::bitset<16> DF307; | ||||
|     std::bitset<32> DF308; | ||||
|     std::bitset<16> DF309; | ||||
|     std::bitset<32> DF310; | ||||
|     std::bitset<24> DF311; | ||||
|     std::bitset<10> DF312; | ||||
|     std::bitset<2> DF314; | ||||
|     std::bitset<1> DF315; | ||||
|  | ||||
|     std::bitset<2> DF364; | ||||
|  | ||||
|     // Content of message header for MSM1, MSM2, MSM3, MSM4, MSM5, MSM6 and MSM7 | ||||
|     std::bitset<1> DF393; | ||||
|     std::bitset<1> DF394; | ||||
|     std::bitset<1> DF395; | ||||
|     std::bitset<1> DF396; //variable | ||||
|     std::bitset<1> DF409; | ||||
|     std::bitset<1> DF411; | ||||
|     std::bitset<1> DF412; | ||||
|     std::bitset<1> DF417; | ||||
|     std::bitset<1> DF418; | ||||
|  | ||||
|     // Content of Satellite data for MSM4 and MSM6 | ||||
|     std::vector<std::bitset<8> > DF397; // 8*NSAT | ||||
|     std::vector<std::bitset<10> > DF398; // 10*NSAT | ||||
|  | ||||
|     // Content of Satellite data for MSM5 and MSM7 | ||||
|     std::vector<std::bitset<14> > DF399; // 14*NSAT | ||||
|  | ||||
|     // Messages | ||||
|     std::bitset<64> message1001_header; | ||||
|     std::bitset<58> message1001_content; | ||||
|     std::bitset<64> message1002_header; | ||||
|     std::bitset<74> message1002_content; | ||||
|  | ||||
|     std::bitset<488> message1019_content; | ||||
|  | ||||
|     std::bitset<496> message1045_content; | ||||
|  | ||||
|     std::bitset<169> MSM_header; // 169+X | ||||
|  | ||||
|     std::vector<std::bitset<18> > MSM4_content; // 18 * Nsat | ||||
|  | ||||
|     std::vector<std::bitset<36> > MSM5_content; // 36 * Nsat | ||||
|  | ||||
|     std::bitset<122> get_M1001(); | ||||
|     std::bitset<138> get_M1002();  //  GPS observables | ||||
|     std::bitset<488> get_M1019();  // GPS ephemeris | ||||
|     std::bitset<496> get_M1045();  // Galileo ephemeris | ||||
|     std::bitset<152> get_M1005_test(); | ||||
|  | ||||
|     void reset_data_fields (); | ||||
|  | ||||
|     // Transport Layer | ||||
|     std::bitset<8> preamble; | ||||
|     std::bitset<6> reserved_field; | ||||
|     std::bitset<10> message_length; | ||||
|     std::bitset<24> crc_frame; | ||||
|     typedef boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> crc_24_q_type; | ||||
|     crc_24_q_type CRC_RTCM; | ||||
|     std::string add_CRC(const std::string& m); | ||||
|     std::string bin_to_hex(const std::string& s); | ||||
|     std::shared_ptr<Rtcm> rtcm; | ||||
|     bool Print_Message(std::string message); | ||||
| }; | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -41,6 +41,7 @@ set(SYSTEM_PARAMETERS_SOURCES | ||||
| 	 gps_cnav_navigation_message.cc | ||||
| 	 gps_cnav_iono.cc | ||||
| 	 gps_cnav_utc_model.cc | ||||
| 	 rtcm.cc | ||||
| ) | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -63,8 +63,10 @@ Galileo_Ephemeris::Galileo_Ephemeris() | ||||
|     TOW_5 = 0; | ||||
|     // SV status | ||||
|     SISA_3 = 0; | ||||
|     E5a_HS = 0; | ||||
|     E5b_HS_5 = 0; | ||||
|     E1B_HS_5 = 0; | ||||
|     E5a_DVS = false; | ||||
|     E5b_DVS_5 = 0; | ||||
|     E1B_DVS_5 = 0; | ||||
|     BGD_E1E5a_5 = 0;        // E1-E5a Broadcast Group Delay [s] | ||||
|   | ||||
| @@ -85,8 +85,10 @@ public: | ||||
|  | ||||
|     // SV status | ||||
|     double SISA_3; | ||||
|     unsigned int E5a_HS;       //!< E5a Signal Health Status | ||||
|     double E5b_HS_5;           //!< E5b Signal Health Status | ||||
|     double E1B_HS_5;           //!< E1B Signal Health Status | ||||
|     bool E5a_DVS;              //!< E5a Data Validity Status | ||||
|     double E5b_DVS_5;          //!< E5b Data Validity Status | ||||
|     double E1B_DVS_5;          //!< E1B Data Validity Status | ||||
|      | ||||
|   | ||||
| @@ -270,10 +270,10 @@ void Galileo_Fnav_Message::decode_page(std::string data) | ||||
| 	    FNAV_region5_1 = static_cast<bool>(read_navigation_unsigned(data_bits, FNAV_region5_1_bit)); | ||||
| 	    FNAV_BGD_1 = static_cast<double>(read_navigation_signed(data_bits, FNAV_BGD_1_bit)); | ||||
| 	    FNAV_BGD_1 *= FNAV_BGD_1_LSB; | ||||
| 	    FNAV_E5ahs_1 = static_cast<double>(read_navigation_unsigned(data_bits, FNAV_E5ahs_1_bit)); | ||||
| 	    FNAV_E5ahs_1 = static_cast<unsigned int>(read_navigation_unsigned(data_bits, FNAV_E5ahs_1_bit)); | ||||
| 	    FNAV_WN_1 = static_cast<double>(read_navigation_unsigned(data_bits, FNAV_WN_1_bit)); | ||||
| 	    FNAV_TOW_1 = static_cast<double>(read_navigation_unsigned(data_bits, FNAV_TOW_1_bit)); | ||||
| 	    FNAV_E5advs_1 = static_cast<double>(read_navigation_unsigned(data_bits, FNAV_E5advs_1_bit)); | ||||
| 	    FNAV_E5advs_1 = static_cast<bool>(read_navigation_unsigned(data_bits, FNAV_E5advs_1_bit)); | ||||
|  | ||||
| 	    flag_TOW_1 = true; | ||||
| 	    flag_TOW_set = true; | ||||
| @@ -628,6 +628,10 @@ Galileo_Ephemeris Galileo_Fnav_Message::get_ephemeris() | ||||
|     /*GST*/ | ||||
|     ephemeris.WN_5 = FNAV_WN_3;          // Week number | ||||
|     ephemeris.TOW_5 = FNAV_TOW_3;        // Time of Week | ||||
|  | ||||
|     /* Health status */ | ||||
|     ephemeris.E5a_HS = FNAV_E5ahs_1; | ||||
|     ephemeris.E5a_DVS = FNAV_E5advs_1; | ||||
|     return ephemeris; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -127,7 +127,7 @@ public: | ||||
|     double FNAV_E5ahs_1; | ||||
|     double FNAV_WN_1; | ||||
|     double FNAV_TOW_1; | ||||
|     double FNAV_E5advs_1; | ||||
|     bool FNAV_E5advs_1; | ||||
|  | ||||
|     // WORD 2 Ephemeris (1/3) and GST | ||||
|     int FNAV_IODnav_2; | ||||
| @@ -186,7 +186,7 @@ public: | ||||
|     double FNAV_M0_1_5; | ||||
|     double FNAV_af0_1_5; | ||||
|     double FNAV_af1_1_5; | ||||
|     double FNAV_E5ahs_1_5; | ||||
|     unsigned int FNAV_E5ahs_1_5; | ||||
|     int FNAV_SVID2_5; | ||||
|     double FNAV_Deltaa12_2_5; | ||||
|     double FNAV_e_2_5; | ||||
|   | ||||
							
								
								
									
										1577
									
								
								src/core/system_parameters/rtcm.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1577
									
								
								src/core/system_parameters/rtcm.cc
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										416
									
								
								src/core/system_parameters/rtcm.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										416
									
								
								src/core/system_parameters/rtcm.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,416 @@ | ||||
| /*! | ||||
|  * \file rtcm.h | ||||
|  * \brief  Interface for the RTCM 3.2 Standard | ||||
|  * \author Carles Fernandez-Prades, 2015. cfernandez(at)cttc.es | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|  * Copyright (C) 2010-2015  (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * 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 | ||||
|  * along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
|  | ||||
| #ifndef GNSS_SDR_RTCM_H_ | ||||
| #define GNSS_SDR_RTCM_H_ | ||||
|  | ||||
|  | ||||
| #include <bitset>   // std::bitset | ||||
| #include <map> | ||||
| #include <string>   // std::string | ||||
| #include <vector> | ||||
| #include <boost/crc.hpp> | ||||
| #include "gnss_synchro.h" | ||||
| #include "galileo_fnav_message.h" | ||||
| #include "gps_navigation_message.h" | ||||
|  | ||||
| /*! | ||||
|  * \brief This class implements the RTCM 3.2 Stardard | ||||
|  * | ||||
|  */ | ||||
| class Rtcm | ||||
| { | ||||
| public: | ||||
|     Rtcm(); | ||||
|  | ||||
|     std::string print_M1001(const Gps_Ephemeris& gps_eph, double obs_time, const std::map<int, Gnss_Synchro> & pseudoranges); | ||||
|  | ||||
|     std::string print_M1045(const Galileo_Ephemeris & gal_eph); //<! Galileo Ephemeris, should be broadcast every 2 minutes | ||||
|  | ||||
|     /*! | ||||
|      * \brief GPS Ephemeris, should be broadcast in the event that the IODC does not match the IODE, and every 2 minutes. | ||||
|      */ | ||||
|     std::string print_M1019(const Gps_Ephemeris & gps_eph); | ||||
|     int read_M1019(const std::string & message, Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|  | ||||
|  | ||||
|     std::string bin_to_hex(const std::string& s); | ||||
|  | ||||
|     std::string hex_to_bin(const std::string& s); | ||||
|  | ||||
|     unsigned long int bin_to_uint(const std::string& s); | ||||
|     long int bin_to_int(const std::string& s); | ||||
|  | ||||
|     unsigned long int hex_to_uint(const std::string& s); | ||||
|     long int hex_to_int(const std::string& s); | ||||
|  | ||||
|     double bin_to_double(const std::string& s); | ||||
|  | ||||
|     std::string print_M1005_test(); //<! For testing purposes | ||||
|     int read_M1005(const std::string & message, unsigned int & ref_id, double & ecef_x, double & ecef_y, double & ecef_z, bool & gps, bool & glonass, bool & galileo); | ||||
|  | ||||
| private: | ||||
|     // | ||||
|     // Messages | ||||
|     // | ||||
|     std::bitset<64> message1001_header; | ||||
|     std::bitset<58> message1001_content; | ||||
|     std::bitset<64> message1002_header; | ||||
|     std::bitset<74> message1002_content; | ||||
|  | ||||
|     std::bitset<488> message1019_content; | ||||
|  | ||||
|     std::bitset<496> message1045_content; | ||||
|  | ||||
|     std::bitset<169> MSM_header; // 169+X | ||||
|  | ||||
|     std::vector<std::bitset<18> > MSM4_content; // 18 * Nsat | ||||
|  | ||||
|     std::vector<std::bitset<36> > MSM5_content; // 36 * Nsat | ||||
|  | ||||
|  | ||||
|     std::bitset<64> get_M1001_header(const Gps_Ephemeris & gps_eph, | ||||
|             double obs_time, | ||||
|             const std::map<int, Gnss_Synchro> & pseudoranges, | ||||
|             unsigned int ref_id, | ||||
|             unsigned int smooth_int, | ||||
|             bool sync_flag, | ||||
|             bool divergence_free); | ||||
|  | ||||
|     std::bitset<58> get_M1001_sat_content(const Gnss_Synchro & gnss_synchro); | ||||
|  | ||||
|     std::bitset<138> get_M1002();  //  GPS observables | ||||
|     //std::bitset<488> get_M1019();  // GPS ephemeris | ||||
|     //std::bitset<496> get_M1045();  // Galileo ephemeris | ||||
|     std::bitset<152> get_M1005_test(); | ||||
|  | ||||
|  | ||||
|  | ||||
|     // | ||||
|     // Transport Layer | ||||
|     // | ||||
|     std::bitset<8> preamble; | ||||
|     std::bitset<6> reserved_field; | ||||
|     std::bitset<10> message_length; | ||||
|     std::bitset<24> crc_frame; | ||||
|     typedef boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> crc_24_q_type; | ||||
|     crc_24_q_type CRC_RTCM; | ||||
|     std::string add_CRC(const std::string& m); | ||||
|     bool check_CRC(const std::string & message); | ||||
|  | ||||
|     std::string build_message(std::string data); // adds 0s to complete a byte and adds the CRC | ||||
|  | ||||
|  | ||||
|     // | ||||
|     // Data Fields | ||||
|     // | ||||
|     int reset_data_fields(); | ||||
|  | ||||
|     std::bitset<12> DF002; | ||||
|     int set_DF002(unsigned int message_number); | ||||
|  | ||||
|     std::bitset<12> DF003; | ||||
|     int set_DF003(unsigned int ref_station_ID); | ||||
|  | ||||
|     std::bitset<30> DF004; | ||||
|     int set_DF004(const Gps_Ephemeris & gps_eph, double obs_time); | ||||
|  | ||||
|     std::bitset<1> DF005; | ||||
|     int set_DF005(bool sync_flag); | ||||
|  | ||||
|     std::bitset<5> DF006; | ||||
|     int set_DF006(const std::map<int, Gnss_Synchro> & pseudoranges); | ||||
|  | ||||
|     std::bitset<1> DF007; | ||||
|     int set_DF007(bool divergence_free_smoothing_indicator); // 0 - Divergence-free smoothing not used 1 - Divergence-free smoothing used | ||||
|  | ||||
|     std::bitset<3> DF008; | ||||
|     int set_DF008(short int smoothing_interval); | ||||
|  | ||||
|     std::bitset<6> DF009; | ||||
|     int set_DF009(const Gps_Ephemeris & gps_eph); | ||||
|     int set_DF009(const Gnss_Synchro & gnss_synchro); | ||||
|  | ||||
|     std::bitset<1> DF010; | ||||
|     int set_DF010(bool code_indicator); | ||||
|  | ||||
|     std::bitset<24> DF011; | ||||
|     int set_DF011(const Gnss_Synchro & gnss_synchro); | ||||
|  | ||||
|     std::bitset<20> DF012; | ||||
|     int set_DF012(const Gnss_Synchro & gnss_synchro); | ||||
|  | ||||
|     std::bitset<7> DF013; | ||||
|     std::bitset<8> DF014; | ||||
|     int set_DF014(const Gnss_Synchro & gnss_synchro); | ||||
|  | ||||
|     std::bitset<8> DF015; | ||||
|     int set_DF015(const Gnss_Synchro & gnss_synchro); | ||||
|  | ||||
|  | ||||
|     std::bitset<6> DF021; | ||||
|     int set_DF021(); | ||||
|  | ||||
|     std::bitset<1> DF022; | ||||
|     int set_DF022(bool gps_indicator); | ||||
|  | ||||
|     std::bitset<1> DF023; | ||||
|     int set_DF023(bool glonass_indicator); | ||||
|  | ||||
|     std::bitset<1> DF024; | ||||
|     int set_DF024(bool galileo_indicator); | ||||
|  | ||||
|     std::bitset<38> DF025; | ||||
|     int set_DF025(double antenna_ECEF_X_m); | ||||
|  | ||||
|     std::bitset<38> DF026; | ||||
|     int set_DF026(double antenna_ECEF_Y_m); | ||||
|  | ||||
|     std::bitset<38> DF027; | ||||
|     int set_DF027(double antenna_ECEF_Z_m); | ||||
|  | ||||
|     // Contents of GPS Satellite Ephemeris Data, Message Type 1019 | ||||
|     std::bitset<8> DF071; | ||||
|     int set_DF071(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<10> DF076; | ||||
|     int set_DF076(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<4> DF077; | ||||
|     int set_DF077(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<2> DF078; | ||||
|     int set_DF078(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<14> DF079; | ||||
|     int set_DF079(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<8> DF080; | ||||
|     int set_DF080(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<16> DF081; | ||||
|     int set_DF081(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<8> DF082; | ||||
|     int set_DF082(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<16> DF083; | ||||
|     int set_DF083(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<22> DF084; | ||||
|     int set_DF084(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<10> DF085; | ||||
|     int set_DF085(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<16> DF086; | ||||
|     int set_DF086(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<16> DF087; | ||||
|     int set_DF087(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<32> DF088; | ||||
|     int set_DF088(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<16> DF089; | ||||
|     int set_DF089(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<32> DF090; | ||||
|     int set_DF090(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<16> DF091; | ||||
|     int set_DF091(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<32> DF092; | ||||
|     int set_DF092(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<16> DF093; | ||||
|     int set_DF093(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<16> DF094; | ||||
|     int set_DF094(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<32> DF095; | ||||
|     int set_DF095(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<16> DF096; | ||||
|     int set_DF096(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<32> DF097; | ||||
|     int set_DF097(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<16> DF098; | ||||
|     int set_DF098(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<32> DF099; | ||||
|     int set_DF099(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<24> DF100; | ||||
|     int set_DF100(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<8> DF101; | ||||
|     int set_DF101(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<6> DF102; | ||||
|     int set_DF102(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<1> DF103; | ||||
|     int set_DF103(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<1> DF137; | ||||
|     int set_DF137(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|  | ||||
|  | ||||
|     std::bitset<1> DF141; | ||||
|     int set_DF141(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     std::bitset<1> DF142; | ||||
|     int set_DF142(const Gps_Ephemeris & gps_eph); | ||||
|  | ||||
|     // Contents of Galileo F/NAV Satellite Ephemeris Data, Message Type 1045 | ||||
|     std::bitset<6> DF252; | ||||
|     int set_DF252(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<12> DF289; | ||||
|     int set_DF289(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<10> DF290; | ||||
|     int set_DF290(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<8> DF291; | ||||
|     int set_DF291(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<14> DF292; | ||||
|     int set_DF292(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<14> DF293; | ||||
|     int set_DF293(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<6> DF294; | ||||
|     int set_DF294(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<21> DF295; | ||||
|     int set_DF295(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<31> DF296; | ||||
|     int set_DF296(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<16> DF297; | ||||
|     int set_DF297(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<16> DF298; | ||||
|     int set_DF298(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<32> DF299; | ||||
|     int set_DF299(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<16> DF300; | ||||
|     int set_DF300(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<32> DF301; | ||||
|     int set_DF301(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<16> DF302; | ||||
|     int set_DF302(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<32> DF303; | ||||
|     int set_DF303(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<14> DF304; | ||||
|     int set_DF304(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<16> DF305; | ||||
|     int set_DF305(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<32> DF306; | ||||
|     int set_DF306(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<16> DF307; | ||||
|     int set_DF307(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<32> DF308; | ||||
|     int set_DF308(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<16> DF309; | ||||
|     int set_DF309(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<32> DF310; | ||||
|     int set_DF310(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<24> DF311; | ||||
|     int set_DF311(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<10> DF312; | ||||
|     int set_DF312(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<10> DF313; | ||||
|     int set_DF313(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<2> DF314; | ||||
|     int set_DF314(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<1> DF315; | ||||
|     int set_DF315(const Galileo_Ephemeris & gal_eph); | ||||
|  | ||||
|     std::bitset<2> DF364; | ||||
|  | ||||
|     // Content of message header for MSM1, MSM2, MSM3, MSM4, MSM5, MSM6 and MSM7 | ||||
|     std::bitset<1> DF393; | ||||
|     int set_DF393(bool more_messages); //1 indicates that more MSMs follow for given physical time and reference station ID | ||||
|  | ||||
|     std::bitset<64> DF394; | ||||
|     int set_DF394(const std::map<int, Gnss_Synchro> & gnss_synchro); | ||||
|  | ||||
|     std::bitset<32> DF395; | ||||
|     int set_DF395(const std::map<int, Gnss_Synchro> & gnss_synchro); | ||||
|  | ||||
|     //std::bitset<1> DF396; //variable | ||||
|     std::bitset<3> DF409; | ||||
|     int set_DF409(unsigned int iods); | ||||
|  | ||||
|     std::bitset<2> DF411; | ||||
|     std::bitset<2> DF412; | ||||
|     std::bitset<1> DF417; | ||||
|     int set_DF417(bool using_divergence_free_smoothing); | ||||
|  | ||||
|     std::bitset<3> DF418; | ||||
|  | ||||
|     // Content of Satellite data for MSM4 and MSM6 | ||||
|     std::vector<std::bitset<8> > DF397; // 8*NSAT | ||||
|     std::vector<std::bitset<10> > DF398; // 10*NSAT | ||||
|  | ||||
|     // Content of Satellite data for MSM5 and MSM7 | ||||
|     std::vector<std::bitset<14> > DF399; // 14*NSAT | ||||
| }; | ||||
|  | ||||
| #endif | ||||
| @@ -37,6 +37,9 @@ | ||||
| #include "gps_ephemeris.h" | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| TEST(Rtcm_Printer_Test, Instantiate) | ||||
| { | ||||
|     std::string filename = "hello.rtcm"; | ||||
| @@ -73,3 +76,83 @@ TEST(Rtcm_Printer_Test, Instantiate_and_Run) | ||||
|  | ||||
|     EXPECT_EQ(reference_msg, testing_msg); | ||||
| } | ||||
|  | ||||
| TEST(Rtcm_Printer_Test, Bin_to_hex) | ||||
| { | ||||
|     auto  rtcm = std::make_shared<Rtcm>(); | ||||
|  | ||||
|     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")); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| TEST(Rtcm_Printer_Test, Hex_to_int) | ||||
| { | ||||
|     auto  rtcm = std::make_shared<Rtcm>(); | ||||
|  | ||||
|     std::string test1 = "2A"; | ||||
|     long int test1_int = rtcm->hex_to_int(test1); | ||||
|     long int expected1 = 42; | ||||
|     EXPECT_EQ(expected1, test1_int); | ||||
| } | ||||
|  | ||||
| TEST(Rtcm_Printer_Test, Bin_to_double) | ||||
| { | ||||
|     auto  rtcm = std::make_shared<Rtcm>(); | ||||
|  | ||||
|     std::bitset<4> test1(5); | ||||
|     long int test1_int = static_cast<long int>(rtcm->bin_to_double(test1.to_string())); | ||||
|     long int expected1 = 5; | ||||
|     EXPECT_EQ(expected1, test1_int); | ||||
|  | ||||
|     std::bitset<4> test2(-5); | ||||
|     long int test2_int = static_cast<long int>(rtcm->bin_to_double(test2.to_string())); | ||||
|     long int expected2 = -5; | ||||
|     EXPECT_EQ(expected2, test2_int); | ||||
|  | ||||
|     std::bitset<65> test3(-5); | ||||
|     long int test3_int = static_cast<long int>(rtcm->bin_to_double(test3.to_string())); | ||||
|     long int expected3 = 0; | ||||
|     EXPECT_EQ(expected3, test3_int); | ||||
| } | ||||
|  | ||||
|  | ||||
| TEST(Rtcm_Printer_Test, Read_M1005) | ||||
| { | ||||
|     std::string filename = "hello.rtcm"; | ||||
|     bool flag_rtcm_tty_port = false; | ||||
|     std::string rtcm_dump_devname = "/dev/pts/4"; | ||||
|  | ||||
|     auto rtcm = std::make_shared<Rtcm>(); | ||||
|     auto rtcm_printer = std::make_shared<Rtcm_Printer>(filename, flag_rtcm_tty_port, rtcm_dump_devname); | ||||
|     std::string reference_msg = rtcm_printer->print_M1005_test(); | ||||
|  | ||||
|     unsigned int ref_id; | ||||
|     double ecef_x; | ||||
|     double ecef_y; | ||||
|     double ecef_z; | ||||
|     bool gps; | ||||
|     bool glonass; | ||||
|     bool galileo; | ||||
|  | ||||
|     rtcm->read_M1005(reference_msg, ref_id, ecef_x, ecef_y, ecef_z, gps, glonass, galileo); | ||||
|  | ||||
|     EXPECT_EQ(true, gps); | ||||
|     EXPECT_EQ(false, glonass); | ||||
|     EXPECT_EQ(false, galileo); | ||||
|  | ||||
|     EXPECT_EQ(2003, ref_id); | ||||
|     EXPECT_DOUBLE_EQ(1114104.5999, ecef_x); | ||||
|     EXPECT_DOUBLE_EQ(-4850729.7108, ecef_y); | ||||
|     EXPECT_DOUBLE_EQ(3975521.4643, ecef_z); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez