Skip to content

Commit

Permalink
host: change UHD pointer types based on UHD version
Browse files Browse the repository at this point in the history
Follow-up: 58b4d86
  • Loading branch information
dsseng authored and chemeris committed Nov 26, 2023
1 parent dbbedb5 commit 4867d84
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
12 changes: 12 additions & 0 deletions host/umtrx_common.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef INCLUDED_UMTRX_COMMON_HPP
#define INCLUDED_UMTRX_COMMON_HPP

#include <uhd/version.hpp>

#if UHD_VERSION >= 4000000
#define UMTRX_UHD_PTR_NAMESPACE std
#else
#define UMTRX_UHD_PTR_NAMESPACE boost
#endif

#endif /* INCLUDED_UMTRX_COMMON_HPP */
4 changes: 3 additions & 1 deletion host/umtrx_fifo_ctrl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
#include <uhd/types/wb_iface.hpp>
#include <string>

#include "umtrx_common.hpp"

/*!
* The umtrx FIFO control class:
* Provide high-speed peek/poke interface.
*/
class umtrx_fifo_ctrl : public uhd::wb_iface, public uhd::spi_iface
{
public:
typedef std::shared_ptr<umtrx_fifo_ctrl> sptr;
typedef UMTRX_UHD_PTR_NAMESPACE::shared_ptr<umtrx_fifo_ctrl> sptr;

//! Make a new FIFO control object
static sptr make(uhd::transport::zero_copy_if::sptr xport, const boost::uint32_t sid, const size_t window_size);
Expand Down
4 changes: 3 additions & 1 deletion host/umtrx_iface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
#include <boost/function.hpp>
#include <string>

#include "umtrx_common.hpp"

/*!
* The umtrx interface class:
* Provides a set of functions to implementation layer.
* Including spi, peek, poke, control...
*/
class umtrx_iface : public uhd::wb_iface, public uhd::spi_iface, public uhd::i2c_iface{
public:
typedef std::shared_ptr<umtrx_iface> sptr;
typedef UMTRX_UHD_PTR_NAMESPACE::shared_ptr<umtrx_iface> sptr;
/*!
* Make a new umtrx interface with the control transport.
* \param ctrl_transport the udp transport object
Expand Down
5 changes: 3 additions & 2 deletions host/umtrx_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define INCLUDED_UMTRX_IMPL_HPP

#include "usrp2/fw_common.h"
#include "umtrx_common.hpp"
#include "umtrx_iface.hpp"
#include "umtrx_fifo_ctrl.hpp"
#include "lms6002d_ctrl.hpp"
Expand Down Expand Up @@ -236,8 +237,8 @@ class umtrx_impl : public uhd::device {
void client_query_handle1(const boost::property_tree::ptree &request, boost::property_tree::ptree &response);

//streaming
std::vector<std::weak_ptr<uhd::rx_streamer> > _rx_streamers;
std::vector<std::weak_ptr<uhd::tx_streamer> > _tx_streamers;
std::vector<UMTRX_UHD_PTR_NAMESPACE::weak_ptr<uhd::rx_streamer> > _rx_streamers;
std::vector<UMTRX_UHD_PTR_NAMESPACE::weak_ptr<uhd::tx_streamer> > _tx_streamers;
boost::mutex _setupMutex;
};

Expand Down
20 changes: 10 additions & 10 deletions host/umtrx_io_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ void umtrx_impl::update_rates(void)

void umtrx_impl::update_rx_samp_rate(const size_t dsp, const double rate)
{
std::shared_ptr<sph::recv_packet_streamer> my_streamer =
std::dynamic_pointer_cast<sph::recv_packet_streamer>(_rx_streamers[dsp].lock());
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::recv_packet_streamer> my_streamer =
UMTRX_UHD_PTR_NAMESPACE::dynamic_pointer_cast<sph::recv_packet_streamer>(_rx_streamers[dsp].lock());
if (not my_streamer) return;

my_streamer->set_samp_rate(rate);
Expand All @@ -116,8 +116,8 @@ void umtrx_impl::update_rx_samp_rate(const size_t dsp, const double rate)

void umtrx_impl::update_tx_samp_rate(const size_t dsp, const double rate)
{
std::shared_ptr<sph::send_packet_streamer> my_streamer =
std::dynamic_pointer_cast<sph::send_packet_streamer>(_tx_streamers[dsp].lock());
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::send_packet_streamer> my_streamer =
UMTRX_UHD_PTR_NAMESPACE::dynamic_pointer_cast<sph::send_packet_streamer>(_tx_streamers[dsp].lock());
if (not my_streamer) return;

my_streamer->set_samp_rate(rate);
Expand All @@ -130,15 +130,15 @@ void umtrx_impl::update_tick_rate(const double rate)
//update the tick rate on all existing streamers -> thread safe
for (size_t i = 0; i < _rx_streamers.size(); i++)
{
std::shared_ptr<sph::recv_packet_streamer> my_streamer =
std::dynamic_pointer_cast<sph::recv_packet_streamer>(_rx_streamers[i].lock());
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::recv_packet_streamer> my_streamer =
UMTRX_UHD_PTR_NAMESPACE::dynamic_pointer_cast<sph::recv_packet_streamer>(_rx_streamers[i].lock());
if (not my_streamer) continue;
my_streamer->set_tick_rate(rate);
}
for (size_t i = 0; i < _tx_streamers.size(); i++)
{
std::shared_ptr<sph::send_packet_streamer> my_streamer =
std::dynamic_pointer_cast<sph::send_packet_streamer>(_tx_streamers[i].lock());
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::send_packet_streamer> my_streamer =
UMTRX_UHD_PTR_NAMESPACE::dynamic_pointer_cast<sph::send_packet_streamer>(_tx_streamers[i].lock());
if (not my_streamer) continue;
my_streamer->set_tick_rate(rate);
}
Expand Down Expand Up @@ -228,7 +228,7 @@ uhd::rx_streamer::sptr umtrx_impl::get_rx_stream(const uhd::stream_args_t &args_
const size_t spp = unsigned(args.args.cast<double>("spp", bpp/bpi));

//make the new streamer given the samples per packet
std::shared_ptr<sph::recv_packet_streamer> my_streamer = std::make_shared<sph::recv_packet_streamer>(spp);
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::recv_packet_streamer> my_streamer = UMTRX_UHD_PTR_NAMESPACE::make_shared<sph::recv_packet_streamer>(spp);

//init some streamer stuff
my_streamer->resize(args.channels.size());
Expand Down Expand Up @@ -454,7 +454,7 @@ uhd::tx_streamer::sptr umtrx_impl::get_tx_stream(const uhd::stream_args_t &args_
const size_t spp = bpp/convert::get_bytes_per_item(args.otw_format);

//make the new streamer given the samples per packet
std::shared_ptr<sph::send_packet_streamer> my_streamer = std::make_shared<sph::send_packet_streamer>(spp);
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::send_packet_streamer> my_streamer = UMTRX_UHD_PTR_NAMESPACE::make_shared<sph::send_packet_streamer>(spp);

//init some streamer stuff
my_streamer->resize(args.channels.size());
Expand Down

0 comments on commit 4867d84

Please sign in to comment.