mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 12:10:34 +00:00
Adding timestamp capability to four bits signal source
This commit is contained in:
parent
c97e12dbe0
commit
742113c55f
@ -16,7 +16,6 @@
|
||||
#include "file_timestamp_signal_source.h"
|
||||
#include "gnss_sdr_flags.h"
|
||||
#include "gnss_sdr_string_literals.h"
|
||||
#include "gnss_sdr_timestamp.h"
|
||||
#include <glog/logging.h>
|
||||
#include <string>
|
||||
|
||||
@ -51,10 +50,22 @@ gnss_shared_ptr<gr::block> FileTimestampSignalSource::source() const { return ti
|
||||
|
||||
void FileTimestampSignalSource::create_file_source_hook()
|
||||
{
|
||||
timestamp_block_ = gnss_sdr_make_Timestamp(
|
||||
std::get<0>(itemTypeToSize()),
|
||||
timestamp_file_,
|
||||
timestamp_clock_offset_ms_);
|
||||
if (is_complex() == false)
|
||||
{
|
||||
timestamp_block_ = gnss_sdr_make_Timestamp(
|
||||
std::get<0>(itemTypeToSize()),
|
||||
timestamp_file_,
|
||||
timestamp_clock_offset_ms_,
|
||||
source_item_size() * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
timestamp_block_ = gnss_sdr_make_Timestamp(
|
||||
std::get<0>(itemTypeToSize()),
|
||||
timestamp_file_,
|
||||
timestamp_clock_offset_ms_,
|
||||
source_item_size());
|
||||
}
|
||||
DLOG(INFO) << "timestamp_block_(" << timestamp_block_->unique_id() << ")";
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "four_bit_cpx_file_signal_source.h"
|
||||
#include "configuration_interface.h"
|
||||
#include "gnss_sdr_flags.h"
|
||||
#include "gnss_sdr_string_literals.h"
|
||||
#include <glog/logging.h>
|
||||
|
||||
@ -28,7 +29,9 @@ FourBitCpxFileSignalSource::FourBitCpxFileSignalSource(
|
||||
const std::string& role,
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
Concurrent_Queue<pmt::pmt_t>* queue)
|
||||
: FileSourceBase(configuration, role, "Four_Bit_Cpx_File_Signal_Source"s, queue, "byte"s)
|
||||
: FileSourceBase(configuration, role, "Four_Bit_Cpx_File_Signal_Source"s, queue, "byte"s),
|
||||
timestamp_file_(configuration->property(role + ".timestamp_filename"s, ""s)),
|
||||
timestamp_clock_offset_ms_(configuration->property(role + ".timestamp_clock_offset_ms"s, 0.0))
|
||||
{
|
||||
sample_type_ = configuration->property(role + ".sample_type", "iq"s);
|
||||
// the complex-ness of the input is inferred from the output type
|
||||
@ -54,6 +57,12 @@ FourBitCpxFileSignalSource::FourBitCpxFileSignalSource(
|
||||
{
|
||||
LOG(ERROR) << "This implementation only supports one output stream";
|
||||
}
|
||||
|
||||
// override value with commandline flag, if present
|
||||
if (FLAGS_timestamp_source != "-")
|
||||
{
|
||||
timestamp_file_ = FLAGS_timestamp_source;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +85,7 @@ std::tuple<size_t, bool> FourBitCpxFileSignalSource::itemTypeToSize()
|
||||
|
||||
// 1 byte -> 1 complex samples
|
||||
double FourBitCpxFileSignalSource::packetsPerSample() const { return 1.0; }
|
||||
gnss_shared_ptr<gr::block> FourBitCpxFileSignalSource::source() const { return inter_shorts_to_cpx_; }
|
||||
gnss_shared_ptr<gr::block> FourBitCpxFileSignalSource::source() const { return timestamp_block_; }
|
||||
|
||||
|
||||
void FourBitCpxFileSignalSource::create_file_source_hook()
|
||||
@ -85,6 +94,14 @@ void FourBitCpxFileSignalSource::create_file_source_hook()
|
||||
DLOG(INFO) << "unpack_byte_2bit_cpx_samples(" << unpack_byte_->unique_id() << ")";
|
||||
inter_shorts_to_cpx_ = gr::blocks::interleaved_short_to_complex::make(false, reverse_interleaving_); // I/Q swap enabled
|
||||
DLOG(INFO) << "interleaved_short_to_complex(" << inter_shorts_to_cpx_->unique_id() << ")";
|
||||
if (timestamp_file_.size() > 1)
|
||||
{
|
||||
timestamp_block_ = gnss_sdr_make_Timestamp(sizeof(gr_complex),
|
||||
timestamp_file_,
|
||||
timestamp_clock_offset_ms_,
|
||||
1);
|
||||
DLOG(INFO) << "timestamp_block_(" << timestamp_block_->unique_id() << ")";
|
||||
}
|
||||
}
|
||||
|
||||
void FourBitCpxFileSignalSource::pre_connect_hook(gr::top_block_sptr top_block)
|
||||
@ -92,10 +109,20 @@ void FourBitCpxFileSignalSource::pre_connect_hook(gr::top_block_sptr top_block)
|
||||
top_block->connect(file_source(), 0, unpack_byte_, 0);
|
||||
top_block->connect(unpack_byte_, 0, inter_shorts_to_cpx_, 0);
|
||||
DLOG(INFO) << "connected file_source to unpacker";
|
||||
if (timestamp_file_.size() > 1)
|
||||
{
|
||||
top_block->connect(inter_shorts_to_cpx_, 0, timestamp_block_, 0);
|
||||
DLOG(INFO) << "connected file_source to timestamp_block_";
|
||||
}
|
||||
}
|
||||
|
||||
void FourBitCpxFileSignalSource::pre_disconnect_hook(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (timestamp_file_.size() > 1)
|
||||
{
|
||||
top_block->disconnect(inter_shorts_to_cpx_, 0, timestamp_block_, 0);
|
||||
DLOG(INFO) << "disconnected file_source from timestamp_block_";
|
||||
}
|
||||
top_block->disconnect(file_source(), 0, unpack_byte_, 0);
|
||||
top_block->disconnect(unpack_byte_, 0, inter_shorts_to_cpx_, 0);
|
||||
DLOG(INFO) << "disconnected file_source from unpacker";
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define GNSS_SDR_FOUR_BIT_CPX_FILE_SIGNAL_SOURCE_H
|
||||
|
||||
#include "file_source_base.h"
|
||||
#include "gnss_sdr_timestamp.h"
|
||||
#include "unpack_byte_4bit_samples.h"
|
||||
#include <gnuradio/blocks/interleaved_short_to_complex.h>
|
||||
#include <cstddef>
|
||||
@ -63,6 +64,10 @@ private:
|
||||
gr::blocks::interleaved_short_to_complex::sptr inter_shorts_to_cpx_;
|
||||
std::string sample_type_;
|
||||
bool reverse_interleaving_;
|
||||
|
||||
gnss_shared_ptr<Gnss_Sdr_Timestamp> timestamp_block_;
|
||||
std::string timestamp_file_;
|
||||
double timestamp_clock_offset_ms_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -28,22 +28,23 @@
|
||||
|
||||
|
||||
Gnss_Sdr_Timestamp::Gnss_Sdr_Timestamp(size_t sizeof_stream_item,
|
||||
std::string timestamp_file, double clock_offset_ms)
|
||||
std::string timestamp_file, double clock_offset_ms, int items_to_samples)
|
||||
: gr::sync_block("Timestamp",
|
||||
gr::io_signature::make(1, 20, sizeof_stream_item),
|
||||
gr::io_signature::make(1, 20, sizeof_stream_item)),
|
||||
d_timefile(std::move(timestamp_file)),
|
||||
d_clock_offset_ms(clock_offset_ms),
|
||||
d_fraction_ms_offset(modf(d_clock_offset_ms, &d_integer_ms_offset)), // optional clockoffset parameter to convert UTC timestamps to GPS time in some receiver's configuration
|
||||
d_items_to_samples(items_to_samples),
|
||||
d_next_timetag_samplecount(0),
|
||||
d_get_next_timetag(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
gnss_shared_ptr<Gnss_Sdr_Timestamp> gnss_sdr_make_Timestamp(size_t sizeof_stream_item, std::string timestamp_file, double clock_offset_ms)
|
||||
gnss_shared_ptr<Gnss_Sdr_Timestamp> gnss_sdr_make_Timestamp(size_t sizeof_stream_item, std::string timestamp_file, double clock_offset_ms, int items_to_samples)
|
||||
{
|
||||
gnss_shared_ptr<Gnss_Sdr_Timestamp> Timestamp_(new Gnss_Sdr_Timestamp(sizeof_stream_item, std::move(timestamp_file), clock_offset_ms));
|
||||
gnss_shared_ptr<Gnss_Sdr_Timestamp> Timestamp_(new Gnss_Sdr_Timestamp(sizeof_stream_item, std::move(timestamp_file), clock_offset_ms, items_to_samples));
|
||||
return Timestamp_;
|
||||
}
|
||||
|
||||
@ -110,8 +111,7 @@ int Gnss_Sdr_Timestamp::work(int noutput_items,
|
||||
for (size_t ch = 0; ch < output_items.size(); ch++)
|
||||
{
|
||||
std::memcpy(output_items[ch], input_items[ch], noutput_items * input_signature()->sizeof_stream_item(ch));
|
||||
uint64_t bytes_to_samples = 2; // todo: improve this.. hardcoded 2 bytes -> 1 complex sample!
|
||||
int64_t diff_samplecount = uint64diff(this->nitems_written(ch), d_next_timetag_samplecount * bytes_to_samples);
|
||||
int64_t diff_samplecount = uint64diff(this->nitems_written(ch), d_next_timetag_samplecount * d_items_to_samples);
|
||||
// std::cout << "diff_samplecount: " << diff_samplecount << ", noutput_items: " << noutput_items << "\n";
|
||||
if (diff_samplecount <= noutput_items and std::labs(diff_samplecount) <= noutput_items)
|
||||
{
|
||||
|
@ -39,7 +39,8 @@ class Gnss_Sdr_Timestamp;
|
||||
gnss_shared_ptr<Gnss_Sdr_Timestamp> gnss_sdr_make_Timestamp(
|
||||
size_t sizeof_stream_item,
|
||||
std::string timestamp_file,
|
||||
double clock_offset_ms);
|
||||
double clock_offset_ms,
|
||||
int items_to_samples);
|
||||
|
||||
|
||||
class Gnss_Sdr_Timestamp : public gr::sync_block
|
||||
@ -54,11 +55,13 @@ private:
|
||||
friend gnss_shared_ptr<Gnss_Sdr_Timestamp> gnss_sdr_make_Timestamp(
|
||||
size_t sizeof_stream_item,
|
||||
std::string timestamp_file,
|
||||
double clock_offset_ms);
|
||||
double clock_offset_ms,
|
||||
int items_to_samples);
|
||||
|
||||
Gnss_Sdr_Timestamp(size_t sizeof_stream_item,
|
||||
std::string timestamp_file,
|
||||
double clock_offset_ms);
|
||||
double clock_offset_ms,
|
||||
int items_to_samples);
|
||||
|
||||
int64_t uint64diff(uint64_t first, uint64_t second);
|
||||
bool read_next_timetag();
|
||||
@ -69,6 +72,7 @@ private:
|
||||
double d_fraction_ms_offset;
|
||||
double d_integer_ms_offset;
|
||||
uint64_t d_next_timetag_samplecount;
|
||||
int d_items_to_samples;
|
||||
bool d_get_next_timetag;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user