mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-18 21:23:02 +00:00
Add example application to receive decoded navigation messages
This commit is contained in:
parent
ea88993ef2
commit
26f72075fc
@ -16,11 +16,13 @@ All notable changes to GNSS-SDR will be documented in this file.
|
||||
|
||||
### Improvements in Usability:
|
||||
|
||||
- Added a new monitor to extract the raw data bits in the navigation message and
|
||||
send them elsewhere via UDP. Activated by setting
|
||||
- Added a new monitor to extract the decoded data bits of the navigation
|
||||
messages and send them elsewhere via UDP. Activated by setting
|
||||
`NavDataMonitor.enable_monitor=true`,
|
||||
`NavDataMonitor.client_addresses=127.0.0.1` and `NavDataMonitor.port=1237` in
|
||||
the configuration file. Format described in the `nav_message.proto` file.
|
||||
the configuration file. Format described in the `nav_message.proto` file. A
|
||||
simple listener application written in C++ is included in
|
||||
`src/utils/nav-listener` as a example.
|
||||
|
||||
## [GNSS-SDR v0.0.15](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.15) - 2021-08-23
|
||||
|
||||
|
38
src/utils/nav-listener/CMakeLists.txt
Normal file
38
src/utils/nav-listener/CMakeLists.txt
Normal file
@ -0,0 +1,38 @@
|
||||
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
# This file is part of GNSS-SDR.
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2021 C. Fernandez-Prades cfernandez(at)cttc.es
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required (VERSION 3.9...3.21)
|
||||
project (nav-msg-listener CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
set(Boost_USE_STATIC_LIBS OFF)
|
||||
find_package(Boost COMPONENTS system REQUIRED)
|
||||
|
||||
find_package(Protobuf REQUIRED)
|
||||
if(${Protobuf_VERSION} VERSION_LESS "3.0.0")
|
||||
message(FATAL_ERROR "Fatal error: Protocol Buffers >= v3.0.0 required.")
|
||||
endif()
|
||||
|
||||
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${CMAKE_SOURCE_DIR}/nav_message.proto)
|
||||
|
||||
add_library(navmsg_lib ${CMAKE_SOURCE_DIR}/nav_msg_udp_listener.cc ${PROTO_SRCS})
|
||||
|
||||
target_link_libraries(navmsg_lib
|
||||
PUBLIC
|
||||
Boost::boost
|
||||
Boost::system
|
||||
protobuf::libprotobuf
|
||||
)
|
||||
|
||||
target_include_directories(navmsg_lib
|
||||
PUBLIC
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_executable(nav_msg_listener ${CMAKE_SOURCE_DIR}/main.cc)
|
||||
|
||||
target_link_libraries(nav_msg_listener PUBLIC navmsg_lib)
|
83
src/utils/nav-listener/README.md
Normal file
83
src/utils/nav-listener/README.md
Normal file
@ -0,0 +1,83 @@
|
||||
# nav_msg_listener
|
||||
|
||||
Simple application that retrieves decoded navigation messages produced by
|
||||
GNSS-SDR and prints them in a terminal. This is only for demonstration purposes,
|
||||
as a example on how to retrieve data using the `nav_message.proto` file.
|
||||
|
||||
|
||||
# Build the software
|
||||
|
||||
This software requires [Boost](https://www.boost.org/) and [Protocol
|
||||
Buffers](https://developers.google.com/protocol-buffers).
|
||||
|
||||
In a terminal, type:
|
||||
|
||||
```
|
||||
$ mkdir build && cd build
|
||||
$ cmake ..
|
||||
$ make
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
In order to tell GNSS-SDR to generate those messages, you need to include the
|
||||
lines:
|
||||
|
||||
```
|
||||
NavDataMonitor.enable_monitor=true
|
||||
NavDataMonitor.client_addresses=127.0.0.1 ; destination IP
|
||||
NavDataMonitor.port=1237 ; destination port
|
||||
```
|
||||
|
||||
in your gnss-sdr configuration file. You can specify multiple destination
|
||||
addresses, separated by underscores:
|
||||
|
||||
```
|
||||
NavDataMonitor.client_addresses=79.154.253.31_79.154.253.32
|
||||
```
|
||||
|
||||
Run gnss-sdr with your configuration, and at the same time, from the computer of
|
||||
the client address (or another terminal from the same computer that is executing
|
||||
gnss-sdr if you are using `127.0.0.1`), execute the binary as:
|
||||
|
||||
```
|
||||
$ ./nav_msg_listener 1237
|
||||
```
|
||||
|
||||
where `1237` needs to be the same port as in `NavDataMonitor.port`. As soon as
|
||||
gnss-sdr starts to decode navigation messages, you will see them in your
|
||||
terminal:
|
||||
|
||||
```
|
||||
$ ./nav_msg_listener 1237
|
||||
|
||||
New Data received:
|
||||
System: E
|
||||
Signal: 1B
|
||||
PRN: 11
|
||||
TOW of last symbol [ms]: 75869044
|
||||
Nav message: 000000001001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010011100101110001000000
|
||||
|
||||
New Data received:
|
||||
System: G
|
||||
Signal: 1C
|
||||
PRN: 16
|
||||
TOW of last symbol [ms]: 75870000
|
||||
Nav message: 100010111010101010101000101111000110001011001010010100011100010001000000000000000000000011010100000000101101100001000011000000000000000000000000111111101000010000110110011011000100000101111100000111100110110101000100110100100010011011101001001010011001011111111110000110000000000000000000000010001100
|
||||
|
||||
New Data received:
|
||||
System: E
|
||||
Signal: 5X
|
||||
PRN: 18
|
||||
TOW of last symbol [ms]: 75870260
|
||||
Nav message: 0000100001111110010000010111110100011010010000100000000000000000000000000000000000000000000000000000000010101010000001001011010010100100100100100110101110110101010000100000000000000000111001011100010010100001010100001110101001001101111000000000
|
||||
|
||||
New Data received:
|
||||
System: G
|
||||
Signal: L5
|
||||
PRN: 6
|
||||
TOW of last symbol [ms]: 75871320
|
||||
Nav message: 100010110001100011110001100010110010100111100001110100001000000110110101100101011100110111001101100001011001110110010100101110001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000001010101010111110000000
|
||||
|
||||
```
|
46
src/utils/nav-listener/main.cc
Normal file
46
src/utils/nav-listener/main.cc
Normal file
@ -0,0 +1,46 @@
|
||||
/*!
|
||||
* \file main.cc
|
||||
* \author Carles Fernandez-Prades, 2021. cfernandez(at)cttc.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "nav_msg_udp_listener.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
// Check command line arguments.
|
||||
if (argc != 2)
|
||||
{
|
||||
// Print help.
|
||||
std::cerr << "Usage: nav_msg_listener <port>\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned short port = boost::lexical_cast<unsigned short>(argv[1]);
|
||||
Nav_Msg_Udp_Listener udp_listener(port);
|
||||
|
||||
while (true)
|
||||
{
|
||||
udp_listener.print_content();
|
||||
}
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
16
src/utils/nav-listener/nav_message.proto
Normal file
16
src/utils/nav-listener/nav_message.proto
Normal file
@ -0,0 +1,16 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// SPDX-FileCopyrightText: 2021 Carles Fernandez-Prades <carles.fernandez@cttc.es>
|
||||
syntax = "proto3";
|
||||
|
||||
package gnss_sdr;
|
||||
|
||||
message navMsg {
|
||||
string system = 1; // GNSS constellation: "G" for GPS, "R" for Glonass, "E" for Galileo, and "C" for Beidou.
|
||||
string signal = 2; // GNSS signal: "1C" for GPS L1 C/A, "1B" for Galileo E1b/c, "1G" for Glonass L1 C/A, "2S" for GPS L2 L2C(M), "2G" for Glonass L2 C/A, "L5" for GPS L5, and "5X" for Galileo E5a
|
||||
int32 prn = 3; // SV ID
|
||||
int32 tow_at_current_symbol_ms = 4; // Time of week of the last symbol received, in ms
|
||||
string nav_message = 5; // for Galileo I/NAV: decoded half page (even or odd), 120 bits, as described in OS SIS ICD 2.0, paragraph 4.3.2.3. I/NAV Page Part
|
||||
// for Galileo F/NAV: decoded word, 244 bits, as described in OS SIS ICD 2.0, paragraph 4.2.2. F/NAV Page Layout
|
||||
// For GPS LNAV: decoded subframe, 300 bits, as described in IS-GPS-200M paragraph 20.3.2 Message Structure.
|
||||
// For GPS CNAV: decoded subframe, 300 bits, as described in IS-GPS-200M paragraph 30.3.3 Message Content.
|
||||
}
|
60
src/utils/nav-listener/nav_msg_udp_listener.cc
Normal file
60
src/utils/nav-listener/nav_msg_udp_listener.cc
Normal file
@ -0,0 +1,60 @@
|
||||
/*!
|
||||
* \file nav_msg_udp_listener.cc
|
||||
* \author Carles Fernandez-Prades, 2021. cfernandez(at)cttc.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "nav_msg_udp_listener.h"
|
||||
#include <sstream>
|
||||
|
||||
Nav_Msg_Udp_Listener::Nav_Msg_Udp_Listener(unsigned short port)
|
||||
: socket{io_service}, endpoint{boost::asio::ip::udp::v4(), port}
|
||||
{
|
||||
socket.open(endpoint.protocol(), error); // Open socket.
|
||||
socket.bind(endpoint, error); // Bind the socket to the given local endpoint.
|
||||
}
|
||||
|
||||
|
||||
bool Nav_Msg_Udp_Listener::read_nav_message(gnss_sdr::navMsg &message)
|
||||
{
|
||||
char buff[1500]; // Buffer for storing the received data.
|
||||
|
||||
message_ = message;
|
||||
// This call will block until one or more bytes of data has been received.
|
||||
int bytes = socket.receive(boost::asio::buffer(buff));
|
||||
|
||||
std::string data(&buff[0], bytes);
|
||||
// Deserialize a stock of Nav_Msg objects from the binary string.
|
||||
return message_.ParseFromString(data);
|
||||
}
|
||||
|
||||
|
||||
bool Nav_Msg_Udp_Listener::print_content()
|
||||
{
|
||||
if (read_nav_message(message_))
|
||||
{
|
||||
std::cout << "\nNew Data received:\n";
|
||||
std::cout << "System: " << message_.system() << '\n';
|
||||
std::cout << "Signal: " << message_.signal() << '\n';
|
||||
std::cout << "PRN: " << message_.prn() << '\n';
|
||||
std::cout << "TOW of last symbol [ms]: "
|
||||
<< message_.tow_at_current_symbol_ms() << '\n';
|
||||
std::cout << "Nav message: " << message_.nav_message() << "\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: the message cannot be parsed.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
37
src/utils/nav-listener/nav_msg_udp_listener.h
Normal file
37
src/utils/nav-listener/nav_msg_udp_listener.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*!
|
||||
* \file nav_msg_udp_listener.h
|
||||
* \author Carles Fernandez-Prades, 2021. cfernandez(at)cttc.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef GNSS_SDR_NAV_MSG_UDP_LISTENER_H
|
||||
#define GNSS_SDR_NAV_MSG_UDP_LISTENER_H
|
||||
|
||||
#include "nav_message.pb.h"
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
class Nav_Msg_Udp_Listener
|
||||
{
|
||||
public:
|
||||
Nav_Msg_Udp_Listener(unsigned short port);
|
||||
bool print_content();
|
||||
|
||||
private:
|
||||
bool read_nav_message(gnss_sdr::navMsg &message);
|
||||
boost::asio::io_service io_service;
|
||||
boost::asio::ip::udp::socket socket;
|
||||
boost::system::error_code error;
|
||||
boost::asio::ip::udp::endpoint endpoint;
|
||||
gnss_sdr::navMsg message_;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user