Skip to content

Commit

Permalink
fixed bug with residual data in map_tx_samples
Browse files Browse the repository at this point in the history
  • Loading branch information
maiconkist committed Apr 16, 2019
1 parent 7ca53de commit ce41185
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 40 deletions.
30 changes: 15 additions & 15 deletions grc_blocks/include/hydra/hydra_gr_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
namespace gr {
namespace hydra {

class HYDRA_API hydra_gr_server : virtual public gr::hier_block2
{
public:
typedef boost::shared_ptr<hydra_gr_server> sptr;
class HYDRA_API hydra_gr_server : virtual public gr::hier_block2
{
public:
typedef boost::shared_ptr<hydra_gr_server> sptr;

static sptr make(std::string server_addr);
static sptr make(std::string server_addr);

virtual void set_tx_config(double d_center_frequency,
double d_samp_rate,
size_t d_tx_fft_size,
std::string mode) = 0;
virtual void set_tx_config(double d_center_frequency,
double d_samp_rate,
size_t d_tx_fft_size,
std::string mode) = 0;

virtual void set_rx_config(double d_center_frequency,
double d_samp_rate,
size_t d_tx_fft_size,
std::string mode) = 0;
virtual void set_rx_config(double d_center_frequency,
double d_samp_rate,
size_t d_tx_fft_size,
std::string mode) = 0;

virtual void start_server() = 0;
};
virtual void start_server() = 0;
};
} // namespace hydra
} // namespace gr

Expand Down
1 change: 0 additions & 1 deletion grc_blocks/lib/hydra_gr_client_source_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "hydra/hydra_gr_client_source.h"
#include "hydra/hydra_client.h"


#include <thread>
#include <zmq.hpp>

Expand Down
1 change: 0 additions & 1 deletion grc_blocks/lib/hydra_gr_server_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <string>
#include <hydra/types.h>
#include <hydra/hydra_main.h>
#include <gnuradio/blocks/udp_source.h>

using namespace hydra;

Expand Down
29 changes: 16 additions & 13 deletions include/hydra/hydra_fft.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* -*- c++ -*- */
/*
/*
* Copyright 2016 Trinity Connect Centre.
*
*
* HyDRA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
*
* HyDRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
Expand All @@ -31,15 +31,8 @@

namespace hydra {

class fft_complex
class fft_complex
{
private:
size_t g_fft_size;
bool g_forward;
gr_complex *g_inbuf;
gr_complex *g_outbuf;
fftwf_plan g_plan;

public:
/** CTOR
* @param fft_size
Expand All @@ -49,7 +42,10 @@ class fft_complex

/**
*/
int set_data(const gr_complex *data, size_t len);
void set_data(const gr_complex *data, size_t len);

void reset_inbuf();
void reset_outbuf();

/**
*/
Expand All @@ -63,6 +59,13 @@ class fft_complex
/**
*/
void execute();

private:
size_t g_fft_size;
bool g_forward;
gr_complex *g_inbuf;
gr_complex *g_outbuf;
fftwf_plan g_plan;
};

/* TYPEDEFS for this class */
Expand Down
22 changes: 17 additions & 5 deletions lib/hydra_fft.cc
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* -*- c++ -*- */
/*
/*
* Copyright 2016 Trinity Connect Centre.
*
*
* HyDRA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
*
* HyDRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
Expand All @@ -36,13 +36,25 @@ fft_complex::fft_complex(size_t fft_size, bool forward):
FFTW_MEASURE);
}

int
void
fft_complex::set_data(const gr_complex *data, size_t len)
{
// Copy samples to fft buffer
std::copy(data, data + len, g_inbuf);
}

void
fft_complex::reset_inbuf()
{
std::fill(g_inbuf, g_inbuf + g_fft_size, 0);
}

void
fft_complex::reset_outbuf()
{
std::fill(g_outbuf, g_outbuf + g_fft_size, 0);
}

gr_complex*
fft_complex::get_inbuf()
{
Expand Down
11 changes: 6 additions & 5 deletions lib/hydra_hypervisor.cc
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* -*- c++ -*- */
/*
/*
* Copyright 2016 Trinity Connect Centre.
*
*
* HyDRA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
*
* HyDRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
Expand All @@ -28,7 +28,6 @@

namespace hydra {


Hypervisor::Hypervisor()
{
}
Expand Down Expand Up @@ -224,6 +223,8 @@ Hypervisor::get_tx_window(window &optr, size_t len)
if (g_vradios.size() == 0) return 0;

{
g_ifft_complex->reset_inbuf();

std::lock_guard<std::mutex> _l(vradios_mtx);

for (vradio_vec::iterator it = g_vradios.begin();
Expand Down

0 comments on commit ce41185

Please sign in to comment.