mirror of
https://github.com/saymrwulf/uhd.git
synced 2026-05-14 20:58:09 +00:00
The tick_node was trying to find the current tick rate by only querying active blocks (i.e., blocks that were flagged active-streaming). However, this is not necessary since we require all blocks to run at the same tick rate. In theory, querying active-only ports should be fine, but due to some idiosyncrasies in our current graph code, connecting a single streamer to channel 1 (out of 0, 1) would try and get the info from the wrong port. This is not a fix to the graph code, but the change to tick_node is also appropriate and is sufficient to fix the "late packets on channel 1" issue. This issue would manifest when sending timed packats to channel 1 in a single-channel streamer. The problem is that it wouldn't be able to read the correct tick rate.
65 lines
2.3 KiB
C++
65 lines
2.3 KiB
C++
//
|
|
// Copyright 2014-2015 Ettus Research LLC
|
|
// Copyright 2018 Ettus Research, a National Instruments Company
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
//
|
|
|
|
#include <uhd/rfnoc/tick_node_ctrl.hpp>
|
|
|
|
using namespace uhd::rfnoc;
|
|
|
|
const double tick_node_ctrl::RATE_UNDEFINED = 0;
|
|
|
|
double tick_node_ctrl::get_tick_rate(
|
|
const std::set<node_ctrl_base::sptr>& _explored_nodes)
|
|
{
|
|
// First, see if we've implemented _get_tick_rate()
|
|
{
|
|
double my_tick_rate = _get_tick_rate();
|
|
if (my_tick_rate != RATE_UNDEFINED) {
|
|
return my_tick_rate;
|
|
}
|
|
}
|
|
|
|
// If not, we ask all our neighbours for the tick rate.
|
|
// This will fail if we get different values.
|
|
std::set<node_ctrl_base::sptr> explored_nodes(_explored_nodes);
|
|
explored_nodes.insert(shared_from_this());
|
|
// Here, we need all up- and downstream nodes. Note that we have the rule
|
|
// that there can only be one tick rate in all of the nodes, that means we
|
|
// don't only search active neighbouring nodes.
|
|
std::vector<sptr> neighbouring_tick_nodes =
|
|
find_downstream_node<tick_node_ctrl>(false);
|
|
{
|
|
std::vector<sptr> upstream_neighbouring_tick_nodes =
|
|
find_upstream_node<tick_node_ctrl>(false);
|
|
neighbouring_tick_nodes.insert(neighbouring_tick_nodes.end(),
|
|
upstream_neighbouring_tick_nodes.begin(),
|
|
upstream_neighbouring_tick_nodes.end());
|
|
} // neighbouring_tick_nodes is now initialized
|
|
double ret_val = RATE_UNDEFINED;
|
|
for (const sptr& node : neighbouring_tick_nodes) {
|
|
if (_explored_nodes.count(node)) {
|
|
continue;
|
|
}
|
|
double tick_rate = node->get_tick_rate(explored_nodes);
|
|
if (tick_rate == RATE_UNDEFINED) {
|
|
continue;
|
|
}
|
|
if (ret_val == RATE_UNDEFINED) {
|
|
ret_val = tick_rate;
|
|
// TODO: Remember name of this node so we can make the throw message more
|
|
// descriptive.
|
|
continue;
|
|
}
|
|
if (tick_rate != ret_val) {
|
|
throw uhd::runtime_error(str(
|
|
// TODO add node names
|
|
boost::format("Conflicting tick rates: One neighbouring block specifies "
|
|
"%d MHz, another %d MHz.")
|
|
% tick_rate % ret_val));
|
|
}
|
|
}
|
|
return ret_val;
|
|
}
|