GNU Radio C++ API Reference 3.10.12.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
message_debug.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2005,2012-2013 Free Software Foundation, Inc.
4 * Copyright 2022,2023 Marcus Müller
5 *
6 * This file is part of GNU Radio
7 *
8 * SPDX-License-Identifier: GPL-3.0-or-later
9 *
10 */
11
12#ifndef INCLUDED_GR_MESSAGE_DEBUG_H
13#define INCLUDED_GR_MESSAGE_DEBUG_H
14
15#include <gnuradio/block.h>
16#include <gnuradio/blocks/api.h>
17#include <spdlog/common.h>
18
19namespace gr {
20namespace blocks {
21
22/*!
23 * \brief Debug block for the message passing system.
24 * \ingroup message_tools_blk
25 * \ingroup measurement_tools_blk
26 * \ingroup debug_tools_blk
27 *
28 * \details
29 * The message debug block is used to capture and print or store
30 * messages as they are received. Any block that generates a
31 * message may connect that message port to one or more of the
32 * two message input ports of this debug block. The message
33 * ports are:
34 *
35 * \li print: prints the message directly to standard out.
36 * \li store: stores the message in an internal vector. May be
37 * access using the get_message function.
38 * \li print_pdu: DEPRECATED! use print() for all printing
39 */
40class BLOCKS_API message_debug : virtual public block
41{
42public:
43 // gr::blocks::message_debug::sptr
44 typedef std::shared_ptr<message_debug> sptr;
45
46 /*!
47 * \brief Build the message debug block. It takes a single parameter that can be used
48 * to disable PDU vector printing and has two message ports: print and store.
49 *
50 * \param en_uvec Enable PDU Vector Printing.
51 * \param log_level The log level of the `log` port. Defaults to "info".
52 */
53 static sptr make(bool en_uvec = true,
54 spdlog::level::level_enum log_level = spdlog::level::info);
55
56 /*!
57 * \brief Reports the number of messages received by this block.
58 */
59 virtual size_t num_messages() = 0;
60
61 /*!
62 * \brief Get a message (as a PMT) from the message vector at index \p i.
63 *
64 * Messages passed to the 'store' port will be stored in a
65 * vector. This function retrieves those messages by index. They
66 * are index in order of when they were received (all messages
67 * are just pushed onto the back of a vector). This is mostly
68 * useful in debugging message passing graphs and in QA code.
69 *
70 * \param i The index in the vector for the message to retrieve.
71 *
72 * \return a message at index \p i as a pmt_t.
73 */
74 virtual pmt::pmt_t get_message(size_t i) = 0;
75
76 /*!
77 * \brief Enables or disables printing of PDU uniform vector data.
78 */
79 virtual void set_vector_print(bool en) = 0;
80
81 /*!
82 * \brief get the log level
83 */
84 virtual spdlog::level::level_enum level() const = 0;
85 /*!
86 * \brief set the log level
87 */
88 virtual void set_level(spdlog::level::level_enum log_level) = 0;
89};
90
91} /* namespace blocks */
92} /* namespace gr */
93
94#endif /* INCLUDED_GR_MESSAGE_DEBUG_H */
The abstract base class for all 'terminal' processing blocks.
Definition gnuradio-runtime/include/gnuradio/block.h:63
Debug block for the message passing system.
Definition message_debug.h:41
virtual spdlog::level::level_enum level() const =0
get the log level
std::shared_ptr< message_debug > sptr
Definition message_debug.h:44
static sptr make(bool en_uvec=true, spdlog::level::level_enum log_level=spdlog::level::info)
Build the message debug block. It takes a single parameter that can be used to disable PDU vector pri...
virtual void set_level(spdlog::level::level_enum log_level)=0
set the log level
virtual pmt::pmt_t get_message(size_t i)=0
Get a message (as a PMT) from the message vector at index i.
virtual size_t num_messages()=0
Reports the number of messages received by this block.
virtual void set_vector_print(bool en)=0
Enables or disables printing of PDU uniform vector data.
#define BLOCKS_API
Definition gr-blocks/include/gnuradio/blocks/api.h:18
GNU Radio logging wrapper.
Definition basic_block.h:29
spdlog::level::level_enum log_level
Definition logger.h:50
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition pmt.h:83