1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-18 21:23:02 +00:00

Consider CI/CD comments (x2)

This commit is contained in:
cesaaargm 2024-07-25 16:00:43 +02:00
parent 95aea155f0
commit e0506eaf9b
7 changed files with 88 additions and 66 deletions

View File

@ -24,7 +24,7 @@
#include "gnss_satellite.h"
#include "osnma_dsm_reader.h" // for OSNMA_DSM_Reader
#include "osnma_helper.h"
#include "osnma_nav_data_manager.h" // TODO - all these repeated includes, is it good practice to include them in the source file?
#include "osnma_nav_data_manager.h" // TODO - all these repeated includes, is it good practice to include them in the source file?
#include <gnuradio/io_signature.h> // for gr::io_signature::make
#include <algorithm>
#include <cmath>
@ -118,16 +118,15 @@ void osnma_msg_receiver::msg_handler_osnma(const pmt::pmt_t& msg)
std::cout << output_message.str() << std::endl;
process_osnma_message(nma_msg);
} // OSNMA frame received
else if (msg_type_hash_code == typeid(std::shared_ptr<std::tuple<uint32_t, std::string, uint32_t>>).hash_code()) // Navigation data bits for OSNMA received
} // OSNMA frame received
else if (msg_type_hash_code == typeid(std::shared_ptr<std::tuple<uint32_t, std::string, uint32_t>>).hash_code()) // Navigation data bits for OSNMA received
{
// TODO - PRNa is a typo here, I think for d_satellite_nav_data, is PRN_d the name to use
const auto inav_data = wht::any_cast<std::shared_ptr<std::tuple<uint32_t, std::string, uint32_t>>>(pmt::any_ref(msg));
uint32_t PRNa = std::get<0>(*inav_data);
std::string nav_data = std::get<1>(*inav_data);
uint32_t TOW = std::get<2>(*inav_data);
d_nav_data_manager->add_navigation_data(nav_data,PRNa,TOW);
d_nav_data_manager->add_navigation_data(nav_data, PRNa,TOW);
}
else
{
@ -605,7 +604,7 @@ void osnma_msg_receiver::read_and_process_mack_block(const std::shared_ptr<OSNMA
d_osnma_data.d_nav_data.set_tow_sf0(osnma_msg->TOW_sf0);
if (d_kroot_verified || d_tesla_key_verified || d_osnma_data.d_dsm_kroot_message.ts != 0 /*mack parser needs to know the tag size, otherwise cannot parse mack messages*/) // C: 4 ts < ts < 10
{// TODO - correct? with this, MACK would not be processed unless a Kroot is available -- no, if TK available MACK sould go on, this has to change in future
{ // TODO - correct? with this, MACK would not be processed unless a Kroot is available -- no, if TK available MACK sould go on, this has to change in future
read_mack_header();
d_osnma_data.d_mack_message.PRNa = osnma_msg->PRN; // FIXME this is ugly.
d_osnma_data.d_mack_message.TOW = osnma_msg->TOW_sf0;
@ -949,7 +948,7 @@ void osnma_msg_receiver::process_mack_message()
for (auto& it : d_tags_awaiting_verify)
{
bool ret;
if (tag_has_key_available(it.second) && d_nav_data_manager->have_nav_data(it.second))//tag_has_nav_data_available(it.second))
if (tag_has_key_available(it.second) && d_nav_data_manager->have_nav_data(it.second)) // tag_has_nav_data_available(it.second))
{
ret = verify_tag(it.second);
/* TODO - take into account:
@ -1206,7 +1205,7 @@ bool osnma_msg_receiver::verify_tag(Tag& tag) const
computed_mac += static_cast<uint64_t>(mac[4]);
}
tag.computed_tag = computed_mac; // update with computed value
tag.computed_tag = computed_mac; // update with computed value
// Compare computed tag with received one truncated
if (tag.received_tag == computed_mac)
{
@ -1245,7 +1244,7 @@ std::vector<uint8_t> osnma_msg_receiver::build_message(Tag& tag) const
// Add applicable NavData bits to message
std::string applicable_nav_data = d_nav_data_manager->get_navigation_data(tag);
std::vector<uint8_t> applicable_nav_data_bytes = d_helper->bytes(applicable_nav_data);
tag.nav_data = applicable_nav_data; // update tag with applicable data
tag.nav_data = applicable_nav_data; // update tag with applicable data
// Convert and add OSNMA_NavData bytes into the message, taking care of that NMAS has only 2 bits
for (uint8_t byte : applicable_nav_data_bytes)
@ -1814,7 +1813,5 @@ void osnma_msg_receiver::send_data_to_pvt(std::vector<OSNMA_NavData> data)
const auto tmp_obj = std::make_shared<OSNMA_NavData>(data[i]);
this->message_port_pub(pmt::mp("OSNMA_to_PVT"), pmt::make_any(tmp_obj));
}
}
}

View File

@ -111,7 +111,7 @@ private:
std::unique_ptr<OSNMA_DSM_Reader> d_dsm_reader; // osnma parameters parser
std::unique_ptr<Gnss_Crypto> d_crypto; // access to cryptographic functions
std::unique_ptr<Osnma_Helper> d_helper;
std::unique_ptr<OSNMA_nav_data_Manager> d_nav_data_manager; // refactor for holding and processing navigation data
std::unique_ptr<OSNMA_nav_data_Manager> d_nav_data_manager; // refactor for holding and processing navigation data
OSNMA_data d_osnma_data{};

View File

@ -24,7 +24,7 @@ bool OSNMA_NavData::add_nav_data(std::string nav_data)
if (nav_data.size() == 549)
{
d_ephemeris_iono = nav_data;
std::bitset<10> bits(nav_data.substr(0,10));
std::bitset<10> bits(nav_data.substr(0, 10));
IOD_nav = static_cast<uint8_t>(bits.to_ulong());
return true;
}

View File

@ -127,9 +127,7 @@ public:
class OSNMA_NavData
{
public:
OSNMA_NavData(): nav_data_id(id_counter++){
}
OSNMA_NavData(): nav_data_id(id_counter++){}
bool have_this_bits(std::string nav_data);
bool add_nav_data(std::string nav_data);
void update_last_received_timestamp(uint32_t TOW);
@ -141,6 +139,8 @@ public:
uint32_t IOD_nav{0};
std::string get_utc_data() const;
std::string get_ephemeris_data() const;
void set_ephemeris_data(std::string value) {d_ephemeris_iono = value;}
void set_utc_data(std::string value) {d_utc = value;}
bool verified{false};
uint32_t PRNd{0};
uint32_t ADKD{};

View File

@ -1,10 +1,23 @@
//
// Created by cgm on 23/07/24.
//
/*!
* \file osnma_nav_data_manager.cc
* \brief Class for Galileo OSNMA navigation data management
* \author Cesare Ghionoiu-Martinez, 2020-2023 cesare.martinez(at)proton.me
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "osnma_nav_data_manager.h"
#if USE_GLOG_AND_GFLAGS
#include <glog/logging.h> // for DLOG
#include <vector>
#else
#include <absl/log/log.h>
#endif
@ -18,7 +31,7 @@
*/
void OSNMA_nav_data_Manager::add_navigation_data(std::string nav_bits, uint32_t PRNd, uint32_t TOW)
{
if(not have_nav_data(nav_bits, PRNd, TOW))
if (not have_nav_data(nav_bits, PRNd, TOW))
{
_satellite_nav_data[PRNd][TOW].add_nav_data(nav_bits);
_satellite_nav_data[PRNd][TOW].PRNd = PRNd;
@ -36,16 +49,16 @@ void OSNMA_nav_data_Manager::update_nav_data(const std::multimap<uint32_t, Tag>&
// if tag status is verified, look for corresponding OSNMA_NavData and add increase verified tag bits.
if (tag.second.status == Tag::e_verification_status::SUCCESS)
{
if(have_PRNd_nav_data(tag.second.PRN_d))
if (have_PRNd_nav_data(tag.second.PRN_d))
{
std::map<uint32_t, OSNMA_NavData> tow_map = _satellite_nav_data.find(tag.second.PRN_d)->second;
for (auto tow_it = tow_map.begin(); tow_it != tow_map.end(); ++tow_it) // note: starts with smallest (i.e. oldest) navigation dataset
for (auto tow_it = tow_map.begin(); tow_it != tow_map.end(); ++tow_it) // note: starts with smallest (i.e. oldest) navigation dataset
{
std::string nav_data;
if(tag.second.ADKD == 0 || tag.second.ADKD == 12){
if (tag.second.ADKD == 0 || tag.second.ADKD == 12){
nav_data = tow_it->second.get_ephemeris_data();
}
else if(tag.second.ADKD == 4){
else if (tag.second.ADKD == 4){
nav_data = tow_it->second.get_utc_data();
}
// find associated OSNMA_NavData
@ -120,20 +133,20 @@ std::string OSNMA_nav_data_Manager::get_navigation_data(const Tag& tag)
// satellite was found, check if TOW exists in inner map
std::map<uint32_t, OSNMA_NavData> tow_map = prn_it->second;
for (auto tow_it = tow_map.begin(); tow_it != tow_map.end(); ++tow_it) // note: starts with smallest (i.e. oldest) navigation dataset
for (auto tow_it = tow_map.begin(); tow_it != tow_map.end(); ++tow_it) // note: starts with smallest (i.e. oldest) navigation dataset
{
// Check if current key (TOW) fulfills condition
if ((tag.TOW - 30 * tag.cop) <= tow_it->first && tow_it->first <= tag.TOW - 30)
{
if(tag.ADKD == 0 || tag.ADKD == 12)
if (tag.ADKD == 0 || tag.ADKD == 12)
{
if(tow_it->second.get_ephemeris_data() != ""){
if (tow_it->second.get_ephemeris_data() != ""){
return tow_it->second.get_ephemeris_data();
}
}
else if(tag.ADKD == 4)
{
if(tow_it->second.get_utc_data() != ""){
if (tow_it->second.get_utc_data() != ""){
return tow_it->second.get_utc_data();
}
}
@ -150,17 +163,17 @@ std::string OSNMA_nav_data_Manager::get_navigation_data(const Tag& tag)
*/
bool OSNMA_nav_data_Manager::have_nav_data(std::string nav_bits, uint32_t PRNd, uint32_t TOW)
{
if(_satellite_nav_data.find(PRNd) != _satellite_nav_data.end()){
if (_satellite_nav_data.find(PRNd) != _satellite_nav_data.end()){
for (auto& data_timestamp : _satellite_nav_data[PRNd])
{
if(nav_bits.size() == EPH_SIZE){
if(data_timestamp.second.get_ephemeris_data() == nav_bits){
if (nav_bits.size() == EPH_SIZE){
if (data_timestamp.second.get_ephemeris_data() == nav_bits){
data_timestamp.second.update_last_received_timestamp(TOW);
return true;
}
}
else if(nav_bits.size() == UTC_SIZE){
if(data_timestamp.second.get_utc_data() == nav_bits){
else if (nav_bits.size() == UTC_SIZE){
if (data_timestamp.second.get_utc_data() == nav_bits){
data_timestamp.second.update_last_received_timestamp(TOW);
return true;
}
@ -182,24 +195,23 @@ bool OSNMA_nav_data_Manager::have_nav_data(const Tag& t) const
}
// satellite was found, check if TOW exists in inner map
std::map<uint32_t, OSNMA_NavData> tow_map = prn_it->second;
for (auto tow_it = tow_map.begin(); tow_it != tow_map.end(); ++tow_it) // note: starts with smallest (i.e. oldest) navigation dataset
for (auto tow_it = tow_map.begin(); tow_it != tow_map.end(); ++tow_it) // note: starts with smallest (i.e. oldest) navigation dataset
{
// Check if current key (TOW) fulfills condition
if (t.TOW - 30 * t.cop <= tow_it->first && tow_it->first <= t.TOW - 30)
{
if(t.ADKD == 0 || t.ADKD == 12)
if (t.ADKD == 0 || t.ADKD == 12)
{
if(tow_it->second.get_ephemeris_data() != ""){
if (tow_it->second.get_ephemeris_data() != ""){
return true;
}
}
else if(t.ADKD == 4)
else if (t.ADKD == 4)
{
if(tow_it->second.get_utc_data() != ""){
if (tow_it->second.get_utc_data() != ""){
return true;
}
}
}
}
return false;

View File

@ -1,13 +1,26 @@
//
// Created by cgm on 23/07/24.
//
/*!
* \file osnma_nav_data_manager.h
* \brief Class for Galileo OSNMA navigation data management
* \author Cesare Ghionoiu-Martinez, 2020-2023 cesare.martinez(at)proton.me
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_OSNMA_NAV_DATA_MANAGER_H
#define GNSS_SDR_OSNMA_NAV_DATA_MANAGER_H
#include "osnma_data.h" // NavData
#include <cstdint> // uint32_t
#include "osnma_data.h" // NavData
#include <cstdint> // uint32_t
#include <map>
#include <vector>
#include <string>
/**
@ -22,7 +35,7 @@ public:
bool have_nav_data(std::string nav_bits, uint32_t PRNd, uint32_t TOW);
bool have_nav_data(uint32_t PRNd, uint32_t TOW, uint8_t ADKD);
bool have_nav_data(const Tag& t) const;
void add_navigation_data(std::string nav_bits, uint32_t PRNd, uint32_t TOW); // gets the bits and adds them to the list
void add_navigation_data(std::string nav_bits, uint32_t PRNd, uint32_t TOW); // gets the bits and adds them to the list
std::string get_navigation_data(const Tag& t);
void update_nav_data(const std::multimap<uint32_t, Tag>& tags_verified, const uint8_t tag_size);
@ -31,11 +44,10 @@ public:
private:
bool have_PRNd_nav_data(uint32_t PRNd);
std::map<uint32_t, std::map<uint32_t, OSNMA_NavData>> _satellite_nav_data{}; // NavData sorted by [PRNd][TOW_start]
std::map<uint32_t, std::map<uint32_t, OSNMA_NavData>> _satellite_nav_data{}; // NavData sorted by [PRNd][TOW_start]
const uint32_t L_t_min{40};
const uint16_t EPH_SIZE{549};
const uint16_t UTC_SIZE{141};
const uint16_t MAX_ALLOWED_SIZE{150}; // arbitrary maximum for the navigation data container
const uint16_t MAX_ALLOWED_SIZE{150}; // arbitrary maximum for the navigation data container
};
#endif // GNSS_SDR_OSNMA_NAV_DATA_MANAGER_H

View File

@ -63,7 +63,7 @@ protected:
const uint32_t LEAP_SECONDS = 0; // 13 + 5;
void set_time(std::tm& input);
// std::string log_name {"CONFIG1-2023-08-16-PKID1-OSNMA"};
std::string log_name{"CONFIG2-2023-07-27-PKID2-MT2-OSNMA"};
std::string log_name{"CONFIG2-2023-07-27-PKID2-MT2-OSNMA"}; // TODO - google::InitGoogleLogging(log_name.c_str()); but cannot be called twice
void initializeGoogleLog();
void SetUp() override
@ -174,7 +174,7 @@ TEST_F(OsnmaMsgReceiverTest, BuildTagMessageM0)
osnma->d_osnma_data.d_dsm_kroot_message.ts = 9; // 40 bit
osnma->d_tesla_keys[TOW_Key_Tag0] = {0x69, 0xC0, 0x0A, 0xA7, 0x36, 0x42, 0x37, 0xA6, 0x5E, 0xBF, 0x00, 0x6A, 0xD8, 0xDB, 0xBC, 0x73}; // K4
osnma->d_osnma_data.d_dsm_kroot_message.mf = 0;
osnma->d_satellite_nav_data[PRNa][TOW_NavData].set_ephemeris_iono_data(
osnma->d_nav_data_manager->add_navigation_data(
"000011101001011001000100000101000111010110100100100101100000000000"
"011101101011001111101110101010000001010000011011111100000011101011"
"011100101101011010101011011011001001110111101011110110111111001111"
@ -183,7 +183,8 @@ TEST_F(OsnmaMsgReceiverTest, BuildTagMessageM0)
"110100010001000110001110011010110000111010000010000000000001101000"
"000000000011100101100100010000000000000110110100110001111100000000"
"000000100110100000000101010010100000001011000010001001100000011111"
"110111111111000000000");
"110111111111000000000",
PRNa, TOW_NavData);
osnma->d_osnma_data.d_nma_header.nmas = 0b10;
MACK_tag_and_info MTI;
@ -216,17 +217,16 @@ TEST_F(OsnmaMsgReceiverTest, TagVerification)
osnma->d_osnma_data.d_dsm_kroot_message.ts = 9; // 40 bit
osnma->d_tesla_keys[TOW_Key_Tag0] = {0x69, 0xC0, 0x0A, 0xA7, 0x36, 0x42, 0x37, 0xA6, 0x5E, 0xBF, 0x00, 0x6A, 0xD8, 0xDD, 0xBC, 0x73}; // K4
osnma->d_osnma_data.d_dsm_kroot_message.mf = 0;
osnma->d_satellite_nav_data[PRNa][TOW_NavData].set_ephemeris_iono_data("");
osnma->d_satellite_nav_data[PRNa][TOW_NavData].set_ephemeris_iono_data(
"000011101001011001000100000101000111010110100100100101100000000000"
"011101101011001111101110101010000001010000011011111100000011101011"
"011100101101011010101011011011001001110111101011110110111111001111"
"001000011111101110011000111111110111111010000011101011111111110000"
"110111000000100000001110110000110110001110000100001110101100010100"
"110100010001000110001110011010110000111010000010000000000001101000"
"000000000011100101100100010000000000000110110100110001111100000000"
"000000100110100000000101010010100000001011000010001001100000011111"
"110111111111000000000");
osnma->d_nav_data_manager->add_navigation_data(
"000011101001011001000100000101000111010110100100100101100000000000"
"011101101011001111101110101010000001010000011011111100000011101011"
"011100101101011010101011011011001001110111101011110110111111001111"
"001000011111101110011000111111110111111010000011101011111111110000"
"110111000000100000001110110000110110001110000100001110101100010100"
"110100010001000110001110011010110000111010000010000000000001101000"
"000000000011100101100100010000000000000110110100110001111100000000"
"000000100110100000000101010010100000001011000010001001100000011111"
"110111111111000000000", PRNa, TOW_NavData);
osnma->d_osnma_data.d_nma_header.nmas = 0b10;
MACK_tag_and_info MTI;
@ -252,9 +252,10 @@ TEST_F(OsnmaMsgReceiverTest, TagVerification)
osnma->d_osnma_data.d_dsm_kroot_message.ts = 9; // 40 bit
osnma->d_tesla_keys[TOW_Key_Tag3] = {0x69, 0xC0, 0x0A, 0xA7, 0x36, 0x42, 0x37, 0xA6, 0x5E, 0xBF, 0x00, 0x6A, 0xD8, 0xDD, 0xBC, 0x73}; // K4
osnma->d_osnma_data.d_dsm_kroot_message.mf = 0;
osnma->d_satellite_nav_data[PRNa][TOW_NavData].set_utc_data(
osnma->d_nav_data_manager->add_navigation_data(
"111111111111111111111111111111110000000000000000000000010001001001001000"
"111000001000100111100010010111111111011110111111111001001100000100000000");
"111000001000100111100010010111111111011110111111111001001100000100000"
, PRNa, TOW_NavData);
osnma->d_osnma_data.d_nma_header.nmas = 0b10;
MTI.tag = static_cast<uint64_t>(0x7BB238C883);
@ -648,10 +649,10 @@ void OsnmaMsgReceiverTest::set_time(std::tm& input)
void OsnmaMsgReceiverTest::initializeGoogleLog()
{
google::InitGoogleLogging(log_name.c_str()); // TODO - running all tests causes conflict due to being called twice
// google::InitGoogleLogging(log_name.c_str());
FLAGS_minloglevel = 0; // INFO
FLAGS_logtostderr = 0; // add this line
FLAGS_log_dir = "/home/cgm/CLionProjects/osnma/data/build/src/tests/logs";
// FLAGS_log_dir = "/home/cgm/CLionProjects/osnma/data/logs";
if (FLAGS_log_dir.empty())
{
std::cout << "Logging will be written at "