Skip to content

Commit

Permalink
Merge branch 'rinex_fix' of https://github.com/gnss-sdr/gnss-sdr into…
Browse files Browse the repository at this point in the history
… rinex_fix
  • Loading branch information
carlesfernandez committed Feb 2, 2017
2 parents beb7bc9 + 37d78d3 commit d491718
Show file tree
Hide file tree
Showing 11 changed files with 854 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work (int noutput_items __attribute__

// PLL commands
d_dump_file.write(reinterpret_cast<char*>(&carr_error_hz), sizeof(double));
d_dump_file.write(reinterpret_cast<char*>(&d_carrier_doppler_hz), sizeof(double));
d_dump_file.write(reinterpret_cast<char*>(&carr_error_filt_hz), sizeof(double));

// DLL commands
d_dump_file.write(reinterpret_cast<char*>(&code_error_chips), sizeof(double));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
#


set(SIGNAL_PROCESSING_TESTING_LIB_SOURCES
tracking_obs_reader.cc
set(SIGNAL_PROCESSING_TESTING_LIB_SOURCES
tracking_dump_reader.cc
tlm_dump_reader.cc
tracking_true_obs_reader.cc
)

include_directories(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// Created by javier on 1/2/2017.
//

#include "tlm_dump_reader.h"

bool tlm_dump_reader::read_binary_obs()
{
try {
d_dump_file.read((char *) &TOW_at_current_symbol, sizeof(double));
d_dump_file.read((char *) &Prn_timestamp_ms, sizeof(double));
d_dump_file.read((char *) &d_TOW_at_Preamble, sizeof(double));
}
catch (const std::ifstream::failure &e) {
return false;
}
return true;
}

bool tlm_dump_reader::restart() {
if (d_dump_file.is_open())
{
d_dump_file.clear();
d_dump_file.seekg(0, std::ios::beg);
return true;
}else{
return false;
}
}

long int tlm_dump_reader::num_epochs()
{
std::ifstream::pos_type size;
int number_of_vars_in_epoch=3;
int epoch_size_bytes=sizeof(double)*number_of_vars_in_epoch;
std::ifstream tmpfile( d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
if (tmpfile.is_open())
{
size = tmpfile.tellg();
long int nepoch=size / epoch_size_bytes;
return nepoch;
}else{
return 0;
}
}

bool tlm_dump_reader::open_obs_file(std::string out_file) {
if (d_dump_file.is_open() == false)
{
try
{
d_dump_filename=out_file;
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "TLM dump enabled, Log file: " << d_dump_filename.c_str()<< std::endl;
return true;
}
catch (const std::ifstream::failure & e)
{
std::cout << "Problem opening TLM dump Log file: " << d_dump_filename.c_str()<< std::endl;
return false;
}
}else{
return false;
}
}

tlm_dump_reader::~tlm_dump_reader() {
if (d_dump_file.is_open() == true)
{
d_dump_file.close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Created by javier on 23/1/2017.
//

#ifndef GNSS_SIM_tlm_dump_reader_H
#define GNSS_SIM_tlm_dump_reader_H

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

class tlm_dump_reader {

public:
~tlm_dump_reader();
bool read_binary_obs();
bool restart();
long int num_epochs();
bool open_obs_file(std::string out_file);

//telemetry decoder dump variables
double TOW_at_current_symbol;
double Prn_timestamp_ms;
double d_TOW_at_Preamble;

private:

std::string d_dump_filename;
std::ifstream d_dump_file;

};

#endif //GNSS_SIM_tlm_dump_reader_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
// Created by javier on 1/2/2017.
//

#include "tracking_dump_reader.h"

bool tracking_dump_reader::read_binary_obs()
{
try {
d_dump_file.read((char *) &abs_E, sizeof(float));
d_dump_file.read((char *) &abs_P, sizeof(float));
d_dump_file.read((char *) &abs_L, sizeof(float));
d_dump_file.read((char *) &prompt_I, sizeof(float));
d_dump_file.read((char *) &prompt_Q, sizeof(float));

d_dump_file.read((char *) &PRN_start_sample_count, sizeof(unsigned long int));

d_dump_file.read((char *) &acc_carrier_phase_rad, sizeof(double));
d_dump_file.read((char *) &carrier_doppler_hz, sizeof(double));
d_dump_file.read((char *) &code_freq_chips, sizeof(double));
d_dump_file.read((char *) &carr_error_hz, sizeof(double));
d_dump_file.read((char *) &carr_error_filt_hz, sizeof(double));
d_dump_file.read((char *) &code_error_chips, sizeof(double));
d_dump_file.read((char *) &code_error_filt_chips, sizeof(double));
d_dump_file.read((char *) &CN0_SNV_dB_Hz, sizeof(double));
d_dump_file.read((char *) &carrier_lock_test, sizeof(double));
d_dump_file.read((char *) &aux1, sizeof(double));
d_dump_file.read((char *) &aux2, sizeof(double));

}
catch (const std::ifstream::failure &e) {
return false;
}
return true;
}

bool tracking_dump_reader::restart() {
if (d_dump_file.is_open())
{
d_dump_file.clear();
d_dump_file.seekg(0, std::ios::beg);
return true;
}else{
return false;
}
}

long int tracking_dump_reader::num_epochs()
{
std::ifstream::pos_type size;
int number_of_double_vars=11;
int number_of_float_vars=5;
int epoch_size_bytes=sizeof(unsigned long int)+
sizeof(double)*number_of_double_vars+
sizeof(float)*number_of_float_vars;
std::ifstream tmpfile( d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
if (tmpfile.is_open())
{
size = tmpfile.tellg();
long int nepoch=size / epoch_size_bytes;
return nepoch;
}else{
return 0;
}
}

bool tracking_dump_reader::open_obs_file(std::string out_file) {
if (d_dump_file.is_open() == false)
{
try
{
d_dump_filename=out_file;
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "Tracking dump enabled, Log file: " << d_dump_filename.c_str()<< std::endl;
return true;
}
catch (const std::ifstream::failure & e)
{
std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename.c_str()<< std::endl;
return false;
}
}else{
return false;
}
}

tracking_dump_reader::~tracking_dump_reader() {
if (d_dump_file.is_open() == true)
{
d_dump_file.close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// Created by javier on 23/1/2017.
//

#ifndef GNSS_SIM_tracking_dump_reader_H
#define GNSS_SIM_tracking_dump_reader_H

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

class tracking_dump_reader {

public:
~tracking_dump_reader();
bool read_binary_obs();
bool restart();
long int num_epochs();
bool open_obs_file(std::string out_file);

//tracking dump variables
// EPR
float abs_E;
float abs_P;
float abs_L;
// PROMPT I and Q (to analyze navigation symbols)
float prompt_I;
float prompt_Q;
// PRN start sample stamp
unsigned long int PRN_start_sample_count;

// accumulated carrier phase
double acc_carrier_phase_rad;

// carrier and code frequency
double carrier_doppler_hz;
double code_freq_chips;

// PLL commands
double carr_error_hz;
double carr_error_filt_hz;

// DLL commands
double code_error_chips;
double code_error_filt_chips;

// CN0 and carrier lock test
double CN0_SNV_dB_Hz;
double carrier_lock_test;

// AUX vars (for debug purposes)
double aux1;
double aux2;

private:

std::string d_dump_filename;
std::ifstream d_dump_file;

};

#endif //GNSS_SIM_tracking_dump_reader_H

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
// Created by javier on 1/2/2017.
//

#include "tracking_obs_reader.h"
#include "tracking_true_obs_reader.h"

bool tracking_obs_reader::read_binary_obs(double &signal_timestamp_s,
double &acc_carrier_phase_cycles,
double &doppler_l1_hz,
double &prn_delay_chips,
double &tow)
bool tracking_true_obs_reader::read_binary_obs()
{
try {
d_dump_file.read((char *) &signal_timestamp_s, sizeof(double));
Expand All @@ -18,17 +14,39 @@ bool tracking_obs_reader::read_binary_obs(double &signal_timestamp_s,
d_dump_file.read((char *) &tow, sizeof(double));
}
catch (const std::ifstream::failure &e) {
std::cout << "Exception writing tracking obs dump file " << e.what() << std::endl;
return false;
}
return true;
}

bool tracking_obs_reader::restart() {
d_dump_file.clear();
d_dump_file.seekg(0, std::ios::beg);
bool tracking_true_obs_reader::restart() {
if (d_dump_file.is_open())
{
d_dump_file.clear();
d_dump_file.seekg(0, std::ios::beg);
return true;
}else{
return false;
}
}

long int tracking_true_obs_reader::num_epochs()
{
std::ifstream::pos_type size;
int number_of_vars_in_epoch=5;
int epoch_size_bytes=sizeof(double)*number_of_vars_in_epoch;
std::ifstream tmpfile( d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
if (tmpfile.is_open())
{
size = tmpfile.tellg();
long int nepoch=size / epoch_size_bytes;
return nepoch;
}else{
return 0;
}
}

bool tracking_obs_reader::open_obs_file(std::string out_file) {
bool tracking_true_obs_reader::open_obs_file(std::string out_file) {
if (d_dump_file.is_open() == false)
{
try
Expand All @@ -49,7 +67,7 @@ bool tracking_obs_reader::open_obs_file(std::string out_file) {
}
}

tracking_obs_reader::~tracking_obs_reader() {
tracking_true_obs_reader::~tracking_true_obs_reader() {
if (d_dump_file.is_open() == true)
{
d_dump_file.close();
Expand Down
Loading

0 comments on commit d491718

Please sign in to comment.