GNU Radio C++ API
tag_sink_demo.h
Go to the documentation of this file.
1
/*
2
* Copyright 2011 Free Software Foundation, Inc.
3
*
4
* This file is part of GNU Radio
5
*
6
* GNU Radio is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3, or (at your option)
9
* any later version.
10
*
11
* GNU Radio is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with GNU Radio; see the file COPYING. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street,
19
* Boston, MA 02110-1301, USA.
20
*/
21
22
#include <
gr_sync_block.h
>
23
#include <
gr_io_signature.h
>
24
#include <boost/foreach.hpp>
25
#include <boost/format.hpp>
26
#include <iostream>
27
#include <complex>
28
29
class
tag_sink_demo
:
public
gr_sync_block
{
30
public
:
31
32
tag_sink_demo
(
void
):
33
gr_sync_block
(
34
"uhd tag sink demo"
,
35
gr_make_io_signature
(1, 1, sizeof(std::complex<float>)),
36
gr_make_io_signature
(0, 0, 0)
37
)
38
{
39
//NOP
40
}
41
42
int
work
(
43
int
ninput_items,
44
gr_vector_const_void_star
&input_items,
45
gr_vector_void_star
&output_items
46
){
47
//grab all "rx time" tags in this work call
48
const
uint64_t
samp0_count = this->
nitems_read
(0);
49
std::vector<gr_tag_t> rx_time_tags;
50
get_tags_in_range
(rx_time_tags, 0, samp0_count, samp0_count + ninput_items,
pmt::pmt_string_to_symbol
(
"rx_time"
));
51
52
//print all tags
53
BOOST_FOREACH(
const
gr_tag_t
&rx_time_tag, rx_time_tags){
54
const
uint64_t
count = rx_time_tag.
offset
;
55
const
pmt::pmt_t
&value = rx_time_tag.
value
;
56
57
std::cout << boost::format(
"Full seconds %u, Frac seconds %f"
)
58
%
pmt::pmt_to_uint64
(
pmt_tuple_ref
(value, 0))
59
%
pmt::pmt_to_double
(
pmt_tuple_ref
(value, 1))
60
<< std::endl;
61
}
62
63
return
ninput_items;
64
}
65
};
gr-uhd
examples
tag_sink_demo.h
Generated on Mon Jul 8 2013 17:07:43 for GNU Radio C++ API by
1.8.4