mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-11-15 14:25:00 +00:00
Merge branch 'fix_fpga_post_proc_mode_progr_termination' of https://github.com/mmajoral/gnss-sdr into mmajoral-fix_fpga_post_proc_mode_progr_termination
This commit is contained in:
commit
d8f7214ad2
@ -146,7 +146,7 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con
|
||||
freq_band = "L1L2";
|
||||
}
|
||||
|
||||
thread_file_to_dma = std::thread([&] { run_DMA_process(freq_band, filename_rx1, filename_rx2, enable_DMA_); });
|
||||
thread_file_to_dma = std::thread([&] { run_DMA_process(freq_band, filename_rx1, filename_rx2); });
|
||||
}
|
||||
if (switch_position == 2) // Real-time via AD9361
|
||||
{
|
||||
@ -304,7 +304,9 @@ Ad9361FpgaSignalSource::~Ad9361FpgaSignalSource()
|
||||
/* cleanup and exit */
|
||||
if (switch_position == 0) // read samples from a file via DMA
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(dma_mutex);
|
||||
enable_DMA_ = false; // disable the DMA
|
||||
lock.unlock();
|
||||
if (thread_file_to_dma.joinable())
|
||||
{
|
||||
thread_file_to_dma.join();
|
||||
@ -336,7 +338,7 @@ Ad9361FpgaSignalSource::~Ad9361FpgaSignalSource()
|
||||
}
|
||||
|
||||
|
||||
void Ad9361FpgaSignalSource::run_DMA_process(const std::string &FreqBand, const std::string &Filename1, const std::string &Filename2, bool enable_DMA)
|
||||
void Ad9361FpgaSignalSource::run_DMA_process(const std::string &FreqBand, const std::string &Filename1, const std::string &Filename2)
|
||||
{
|
||||
const int MAX_INPUT_SAMPLES_TOTAL = 16384;
|
||||
int max_value = 0;
|
||||
@ -390,7 +392,8 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &FreqBand, const
|
||||
//**************************************************************************
|
||||
int nsamples = 0;
|
||||
|
||||
while ((file_completed == 0) && (enable_DMA == true))
|
||||
//while ((file_completed == 0) && (enable_DMA == true))
|
||||
while ((file_completed == 0))
|
||||
{
|
||||
unsigned int dma_index = 0;
|
||||
|
||||
@ -410,7 +413,7 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &FreqBand, const
|
||||
}
|
||||
else
|
||||
{
|
||||
nread_elements = 0;
|
||||
nread_elements = infile1.gcount();
|
||||
}
|
||||
nsamples += (nread_elements / 2);
|
||||
|
||||
@ -442,7 +445,7 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &FreqBand, const
|
||||
}
|
||||
else
|
||||
{
|
||||
nread_elements = 0;
|
||||
nread_elements = infile1.gcount();
|
||||
}
|
||||
nsamples += (nread_elements / 2);
|
||||
|
||||
@ -474,7 +477,7 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &FreqBand, const
|
||||
}
|
||||
else
|
||||
{
|
||||
nread_elements = 0;
|
||||
nread_elements = infile1.gcount();
|
||||
}
|
||||
try
|
||||
{
|
||||
@ -490,7 +493,7 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &FreqBand, const
|
||||
}
|
||||
else
|
||||
{
|
||||
nread_elements2 = 0;
|
||||
nread_elements2 = infile2.gcount();
|
||||
}
|
||||
|
||||
if (nread_elements > nread_elements2)
|
||||
@ -551,13 +554,23 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &FreqBand, const
|
||||
{
|
||||
file_completed = 1;
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lock(dma_mutex);
|
||||
if (enable_DMA_ == false)
|
||||
{
|
||||
file_completed = true;
|
||||
}
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
infile1.close();
|
||||
if (FreqBand == "L1L2")
|
||||
{
|
||||
infile2.close();
|
||||
}
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Exception closing files " << Filename1 << " and " << Filename2 << std::endl;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <pmt/pmt.h>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
@ -67,8 +68,7 @@ public:
|
||||
private:
|
||||
void run_DMA_process(const std::string &FreqBand,
|
||||
const std::string &Filename1,
|
||||
const std::string &Filename2,
|
||||
bool enable_DMA);
|
||||
const std::string &Filename2);
|
||||
|
||||
std::thread thread_file_to_dma;
|
||||
|
||||
@ -116,6 +116,8 @@ private:
|
||||
bool rx2_enable_;
|
||||
bool enable_DMA_;
|
||||
bool rf_shutdown_;
|
||||
|
||||
std::mutex dma_mutex;
|
||||
};
|
||||
|
||||
#endif // GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H
|
||||
|
Loading…
Reference in New Issue
Block a user