GNSS-SDR  0.0.21
An Open Source GNSS Software Defined Receiver
nmea_printer.h
Go to the documentation of this file.
1 /*!
2  * \file nmea_printer.h
3  * \brief Interface of a NMEA 2.1 printer for GNSS-SDR
4  * This class provides a implementation of a subset of the NMEA-0183 standard for interfacing
5  * marine electronic devices as defined by the National Marine Electronics Association (NMEA).
6  * See https://www.nmea.org/ for the NMEA 183 standard
7  *
8  * \author Javier Arribas, 2012. jarribas(at)cttc.es
9  *
10  *
11  * -----------------------------------------------------------------------------
12  *
13  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
14  * This file is part of GNSS-SDR.
15  *
16  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
17  * SPDX-License-Identifier: GPL-3.0-or-later
18  *
19  * -----------------------------------------------------------------------------
20  */
21 
22 #ifndef GNSS_SDR_NMEA_PRINTER_H
23 #define GNSS_SDR_NMEA_PRINTER_H
24 
25 #include <boost/date_time/posix_time/ptime.hpp> // for ptime
26 #include <fstream> // for ofstream
27 #include <memory> // for shared_ptr
28 #include <string> // for string
29 
30 /** \addtogroup PVT
31  * \{ */
32 /** \addtogroup PVT_libs
33  * \{ */
34 
35 
36 class Rtklib_Solver;
37 
38 /*!
39  * \brief This class provides a implementation of a subset of the NMEA-0183 standard for interfacing
40  * marine electronic devices as defined by the National Marine Electronics Association (NMEA).
41  *
42  * See https://en.wikipedia.org/wiki/NMEA_0183
43  */
45 {
46 public:
47  /*!
48  * \brief Default constructor.
49  */
50  Nmea_Printer(const std::string& filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string& base_path = ".");
51 
52  /*!
53  * \brief Default destructor.
54  */
55  ~Nmea_Printer();
56 
57  /*!
58  * \brief Print NMEA PVT and satellite info to the initialized device
59  */
60  bool Print_Nmea_Line(const Rtklib_Solver* const pvt_data);
61 
62  /*!
63  * \brief Returns GPGGA message (fix data)
64  */
65  std::string get_GPGGA(const Rtklib_Solver* const pvt_data) const;
66 
67  /*!
68  * \brief Returns GPGSA message (overall satellite reception data)
69  */
70  std::string get_GPGSA(const Rtklib_Solver* const pvt_data) const;
71 
72 private:
73  int init_serial(const std::string& serial_device); // serial port control
74  void close_serial() const;
75  std::string get_GPGGA() const; // fix data
76  std::string get_GPGSV() const; // satellite data
77  std::string get_GPGSA() const; // overall satellite reception data
78  std::string get_GPRMC() const; // minimum recommended data
79  std::string get_UTC_NMEA_time(const boost::posix_time::ptime d_position_UTC_time) const;
80  std::string longitude_to_hm(double longitude) const;
81  std::string latitude_to_hm(double lat) const;
82  char checkSum(const std::string& sentence) const;
83 
84  const Rtklib_Solver* d_PVT_data;
85 
86  std::ofstream nmea_file_descriptor; // Output file stream for NMEA log file
87 
88  std::string nmea_filename; // String with the NMEA log filename
89  std::string nmea_base_path;
90  std::string nmea_devname;
91 
92  int nmea_dev_descriptor; // NMEA serial device descriptor (i.e. COM port)
93  bool d_flag_nmea_output_file;
94 };
95 
96 
97 /** \} */
98 /** \} */
99 #endif // GNSS_SDR_NMEA_PRINTER_H
std::string get_GPGGA(const Rtklib_Solver *const pvt_data) const
Returns GPGGA message (fix data)
std::string get_GPGSA(const Rtklib_Solver *const pvt_data) const
Returns GPGSA message (overall satellite reception data)
~Nmea_Printer()
Default destructor.
This class implements a PVT solution based on RTKLIB.
Definition: rtklib_solver.h:82
This class provides a implementation of a subset of the NMEA-0183 standard for interfacing marine ele...
Definition: nmea_printer.h:44
bool Print_Nmea_Line(const Rtklib_Solver *const pvt_data)
Print NMEA PVT and satellite info to the initialized device.
Nmea_Printer(const std::string &filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string &base_path=".")
Default constructor.