mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-10-27 05:27:40 +00:00
Remove build and data folders, move tests and utils to the base of the source tree
This commit is contained in:
57
utils/nav-listener/CMakeLists.txt
Normal file
57
utils/nav-listener/CMakeLists.txt
Normal file
@@ -0,0 +1,57 @@
|
||||
# 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.30)
|
||||
project(nav-msg-listener CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
set(NAVLISTENER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # allows this to be a sub-project
|
||||
set(NAVLISTENER_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
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 ${NAVLISTENER_SOURCE_DIR}/nav_message.proto)
|
||||
|
||||
add_library(navmsg_lib ${NAVLISTENER_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
|
||||
${NAVLISTENER_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_executable(nav_msg_listener ${NAVLISTENER_SOURCE_DIR}/main.cc)
|
||||
|
||||
target_link_libraries(nav_msg_listener PUBLIC navmsg_lib)
|
||||
|
||||
install(TARGETS nav_msg_listener
|
||||
RUNTIME DESTINATION bin
|
||||
COMPONENT "nav_msg_listener"
|
||||
)
|
||||
|
||||
if(NOT TARGET uninstall)
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY
|
||||
)
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
||||
)
|
||||
endif()
|
||||
103
utils/nav-listener/README.md
Normal file
103
utils/nav-listener/README.md
Normal file
@@ -0,0 +1,103 @@
|
||||
<!-- prettier-ignore-start -->
|
||||
[comment]: # (
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
)
|
||||
|
||||
[comment]: # (
|
||||
SPDX-FileCopyrightText: 2021 Carles Fernandez-Prades <carles.fernandez@cttc.es>
|
||||
)
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
# 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://protobuf.dev/).
|
||||
|
||||
In a terminal, type:
|
||||
|
||||
```
|
||||
$ mkdir build && cd build
|
||||
$ cmake ..
|
||||
$ make
|
||||
```
|
||||
|
||||
Optionally, you can install it:
|
||||
|
||||
```
|
||||
$ sudo make install
|
||||
```
|
||||
|
||||
and uninstall it later with:
|
||||
|
||||
```
|
||||
$ sudo make uninstall
|
||||
```
|
||||
|
||||
## 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
|
||||
|
||||
```
|
||||
35
utils/nav-listener/cmake/cmake_uninstall.cmake.in
Normal file
35
utils/nav-listener/cmake/cmake_uninstall.cmake.in
Normal file
@@ -0,0 +1,35 @@
|
||||
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
# This file is part of GNSS-SDR.
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2011-2020 C. Fernandez-Prades cfernandez(at)cttc.es
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
endif()
|
||||
|
||||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||
foreach(file ${files})
|
||||
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
if(CMAKE_VERSION VERSION_LESS 3.17)
|
||||
execute_process(
|
||||
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RESULT_VARIABLE rm_retval
|
||||
)
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND @CMAKE_COMMAND@ -E rm "$ENV{DESTDIR}${file}"
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RESULT_VARIABLE rm_retval
|
||||
)
|
||||
endif()
|
||||
if(NOT "${rm_retval}" STREQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||
endif()
|
||||
endforeach()
|
||||
61
utils/nav-listener/main.cc
Normal file
61
utils/nav-listener/main.cc
Normal file
@@ -0,0 +1,61 @@
|
||||
/*!
|
||||
* \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);
|
||||
std::cout << "Listening on port " << static_cast<int>(port) << ", press Control+C to exit ...\n";
|
||||
|
||||
while (true)
|
||||
{
|
||||
gnss_sdr::navMsg message;
|
||||
if (udp_listener.receive_and_parse_nav_message(message))
|
||||
{
|
||||
udp_listener.print_message(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: the message cannot be parsed." << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (boost::bad_lexical_cast &)
|
||||
{
|
||||
std::cerr << "Error: the argument " << argv[1] << " is not a valid port number.\n";
|
||||
return 1;
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
17
utils/nav-listener/nav_message.proto
Normal file
17
utils/nav-listener/nav_message.proto
Normal file
@@ -0,0 +1,17 @@
|
||||
// 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, "5X" for Galileo E5a, and "E6" for Galileo E6B.
|
||||
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 Galileo HAS: decoded full HAS message (header + body), variable length, as described in Galileo HAS SIS ICD.
|
||||
// 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.
|
||||
}
|
||||
85
utils/nav-listener/nav_msg_udp_listener.cc
Normal file
85
utils/nav-listener/nav_msg_udp_listener.cc
Normal file
@@ -0,0 +1,85 @@
|
||||
/*!
|
||||
* \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 <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
Nav_Msg_Udp_Listener::Nav_Msg_Udp_Listener(unsigned short port)
|
||||
: socket{io_service}, endpoint{boost::asio::ip::udp::v4(), port}, connected_socket(true)
|
||||
{
|
||||
socket.open(endpoint.protocol(), error); // Open socket
|
||||
if (error)
|
||||
{
|
||||
std::cerr << "Error opening socket: " << error.message() << '\n';
|
||||
connected_socket = false;
|
||||
}
|
||||
if (connected_socket)
|
||||
{
|
||||
socket.bind(endpoint, error); // Bind the socket to the given local endpoint.
|
||||
if (error)
|
||||
{
|
||||
std::cerr << "Error binding socket: " << error.message() << '\n';
|
||||
connected_socket = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Blocking call to read nav_message from UDP port
|
||||
* return true if message parsed succesfully, false ow
|
||||
*/
|
||||
bool Nav_Msg_Udp_Listener::receive_and_parse_nav_message(gnss_sdr::navMsg &message)
|
||||
{
|
||||
if (connected_socket)
|
||||
{
|
||||
char buff[8192]; // Buffer for storing the received data.
|
||||
|
||||
// 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);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Prints navigation message content
|
||||
* param[in] message nav message to be printed
|
||||
*/
|
||||
void Nav_Msg_Udp_Listener::print_message(gnss_sdr::navMsg &message) const
|
||||
{
|
||||
if (connected_socket)
|
||||
{
|
||||
std::string system = message.system();
|
||||
std::string signal = message.signal();
|
||||
int prn = message.prn();
|
||||
int tow_at_current_symbol_ms = message.tow_at_current_symbol_ms();
|
||||
std::string nav_message = message.nav_message();
|
||||
|
||||
std::cout << "\nNew data received:\n";
|
||||
std::cout << "System: " << system << '\n';
|
||||
std::cout << "Signal: " << signal << '\n';
|
||||
std::cout << "PRN: " << prn << '\n';
|
||||
std::cout << "TOW of last symbol [ms]: "
|
||||
<< tow_at_current_symbol_ms << '\n';
|
||||
std::cout << "Nav message: " << nav_message << "\n\n";
|
||||
}
|
||||
}
|
||||
37
utils/nav-listener/nav_msg_udp_listener.h
Normal file
37
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:
|
||||
explicit Nav_Msg_Udp_Listener(unsigned short port);
|
||||
void print_message(gnss_sdr::navMsg &message) const;
|
||||
bool receive_and_parse_nav_message(gnss_sdr::navMsg &message);
|
||||
|
||||
private:
|
||||
boost::asio::io_service io_service;
|
||||
boost::asio::ip::udp::socket socket;
|
||||
boost::system::error_code error;
|
||||
boost::asio::ip::udp::endpoint endpoint;
|
||||
bool connected_socket;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user