GNU Radio C++ API Reference 3.10.12.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
rfnoc_replay.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2023 Ettus Research, a National Instruments Brand.
4 *
5 * SPDX-License-Identifier: GPL-3.0-or-later
6 */
7
8#ifndef INCLUDED_GR_UHD_RFNOC_REPLAY_H
9#define INCLUDED_GR_UHD_RFNOC_REPLAY_H
10
11#include <gnuradio/uhd/api.h>
13
14namespace gr {
15namespace uhd {
16
27
28/*! RFNoC Replay Block
29 *
30 * This wraps a replay block into GNU Radio.
31 *
32 * \ingroup uhd_blk
33 */
34class GR_UHD_API rfnoc_replay : virtual public rfnoc_block
35{
36public:
37 typedef std::shared_ptr<rfnoc_replay> sptr;
38
39 /*!
40 * \param graph Reference to the underlying rfnoc_graph object
41 * \param block_args Additional block arguments
42 * \param device_select Device Selection
43 * \param instance Instance Selection
44 */
46 const ::uhd::device_addr_t& block_args,
47 const int device_select,
48 const int instance);
49
50 /*! Record
51 *
52 * Begin recording. The offset sets the starting location in memory and the size
53 * limits the length of the recording. The flow of data is controlled by upstream
54 * RFNoC blocks.
55 *
56 * \param offset Memory offset where to start recording the data. This value
57 * must be aligned to the memory word size. Use get_word_size() to get the
58 * size of the memory word.
59 * \param size Size limit, in bytes. This value must be aligned to the memory
60 * word size and the item size. Use get_word_size() to get the size of the
61 * memory word and get_item_size() to get the item size. A value of 0 means
62 * to use all available space.
63 * \param port Which input port of the replay block to use
64 * \throws uhd::value_error if offset+size exceeds the available memory.
65 */
66 virtual void
67 record(const uint64_t offset, const uint64_t size, const size_t port = 0) = 0;
68
69 /*! Restarts recording from the record offset
70 *
71 * This is a shortcut for calling record() again with the same arguments.
72 *
73 * \param port Which input port of the replay block to use
74 */
75 virtual void record_restart(const size_t port = 0) = 0;
76
77 /*! Play back data.
78 *
79 * The offset and size define what data is played back on an output port.
80 * It will stream out \p size bytes of data, starting at memory offset
81 * \p offset.
82 *
83 * The data can be played once or repeated continuously until a stop
84 * command is issued. If a time_spec is supplied, it will be placed in the
85 * header of the first packet. Typically, this is used to tell a downstream
86 * Radio block when to start transmitting the data.
87 *
88 * If the data type on the output port is not defined, this function will
89 * throw an error.
90 *
91 * \param offset Memory offset of the data to be played. This value must be
92 * aligned to the size of the word in memory. Use get_word_size()
93 * to get the memory word size.
94 * \param size Size of data to play back. This value must be aligned to the
95 * size of the memory word and item size. Use get_word_size() to
96 * get the memory word size and get_output_item_size() to get
97 * the item size. This value will be used for the num_samps
98 * component of the underlying stream command.
99 * \param port Which output port of the replay block to use
100 * \param time_spec Set the time for the first item. Any non-zero value is
101 * used to set the time in the header of the first packet.
102 * Most commonly, this is used to set the start time of a
103 * transmission. Note that this block will not wait for a
104 * time to occur, rather, it will tag the first outgoing
105 * packet with this time stamp.
106 * \param repeat Determines whether the data should be played repeatedly or
107 * just once. If set to true, stop_playback() must be called to stop
108 * the play back.
109 * \throws uhd::value_error if offset+size exceeds the available memory.
110 * \throws uhd::op_failed Too many play commands are queued.
111 */
112 virtual void play(const uint64_t offset,
113 const uint64_t size,
114 const size_t port = 0,
115 const ::uhd::time_spec_t time_spec = ::uhd::time_spec_t(0.0),
116 const bool repeat = false) = 0;
117
118 /*! Stops playback
119 *
120 * Halts any currently executing play commands and cancels any other play commands
121 * that are waiting to be executed for that output port.
122 *
123 * \param port Which output port of the replay block to use
124 */
125 virtual void stop_playback(const size_t port = 0) = 0;
126
127 /*! Sets the data type for items in the current record buffer for the given input
128 * port.
129 *
130 * \param type The data type
131 * \param port Which input port of the replay block to use
132 */
133 virtual void set_record_type(const std::string type, const size_t port = 0) = 0;
134
135 /*! Sets the data type for items in the current play buffer for the given output port.
136 *
137 * \param type The data type
138 * \param port Which output port of the replay block to use
139 */
140 virtual void set_play_type(const std::string type, const size_t port = 0) = 0;
141
142 /*! Issue a stream command to the replay block
143 *
144 * Issue stream commands to start or stop playback from the configured playback
145 * buffer. Supports
146 * STREAM_MODE_START_CONTINUOUS to start continuous repeating playback,
147 * STREAM_MODE_NUM_SAMPS_AND_DONE to play the given number of samples once, and
148 * STREAM_MODE_STOP_CONTINUOUS to stop all playback immediately.
149 * If a time_spec is supplied, it is placed in the header of the first packet produced
150 * for that command. Commands are queued and executed in order. A
151 * STREAM_MODE_STOP_CONTINUOUS command will halt all playback and purge all commands
152 * in the queue for a given output port.
153 *
154 * \param cmd The command to execute
155 * \param port Which output port of the replay block to use
156 * \throws uhd::op_failed Too many commands are queued.
157 */
158 virtual void issue_stream_cmd(const ::uhd::stream_cmd_t& cmd,
159 const size_t port = 0) = 0;
160};
161
162} // namespace uhd
163} // namespace gr
164
165#endif /* INCLUDED_GR_UHD_RFNOC_REPLAY_H */
Definition rfnoc_block.h:29
std::shared_ptr< rfnoc_graph > sptr
Definition rfnoc_graph.h:32
Definition rfnoc_replay.h:35
virtual void stop_playback(const size_t port=0)=0
virtual void set_record_type(const std::string type, const size_t port=0)=0
virtual void issue_stream_cmd(const ::uhd::stream_cmd_t &cmd, const size_t port=0)=0
virtual void set_play_type(const std::string type, const size_t port=0)=0
virtual void record_restart(const size_t port=0)=0
virtual void record(const uint64_t offset, const uint64_t size, const size_t port=0)=0
static sptr make(rfnoc_graph::sptr graph, const ::uhd::device_addr_t &block_args, const int device_select, const int instance)
std::shared_ptr< rfnoc_replay > sptr
Definition rfnoc_replay.h:37
virtual void play(const uint64_t offset, const uint64_t size, const size_t port=0, const ::uhd::time_spec_t time_spec=::uhd::time_spec_t(0.0), const bool repeat=false)=0
#define GR_UHD_API
Definition gr-uhd/include/gnuradio/uhd/api.h:18
GR_UHD_API const pmt::pmt_t replay_word_size_key()
GR_UHD_API const pmt::pmt_t replay_debug_port_key()
GR_UHD_API const pmt::pmt_t replay_mem_size_key()
GR_UHD_API const pmt::pmt_t replay_mem_fullness_key()
GR_UHD_API const pmt::pmt_t replay_cmd_time_key()
GR_UHD_API const pmt::pmt_t replay_cmd_port_key()
GR_UHD_API const pmt::pmt_t replay_cmd_offset_key()
GR_UHD_API const pmt::pmt_t replay_cmd_repeat_key()
GR_UHD_API const pmt::pmt_t replay_cmd_key()
GR_UHD_API const pmt::pmt_t replay_cmd_size_key()
GNU Radio logging wrapper.
Definition basic_block.h:29
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition pmt.h:83