Imported Upstream version 3.2.2
[debian/gnuradio] / gr-usrp2 / src / usrp2_sink_32fc.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <usrp2_sink_32fc.h>
28 #include <usrp2/metadata.h>
29 #include <gr_io_signature.h>
30 #include <iostream>
31
32 usrp2_sink_32fc_sptr
33 usrp2_make_sink_32fc(const std::string &ifc, const std::string &mac_addr) 
34   throw (std::runtime_error)
35 {
36   return gnuradio::get_initial_sptr(new usrp2_sink_32fc(ifc, mac_addr));
37 }
38
39 usrp2_sink_32fc::usrp2_sink_32fc(const std::string &ifc, const std::string &mac_addr) 
40   throw (std::runtime_error)
41   : usrp2_sink_base("usrp2_sink_32fc",
42                     gr_make_io_signature(1, 1, sizeof(gr_complex)),
43                     ifc, mac_addr)
44 {
45   // NOP
46 }
47
48 usrp2_sink_32fc::~usrp2_sink_32fc()
49 {
50   // NOP
51 }
52
53 int
54 usrp2_sink_32fc::work(int noutput_items,
55                       gr_vector_const_void_star &input_items,
56                       gr_vector_void_star &output_items)
57 {
58   gr_complex *in = (gr_complex *)input_items[0];
59
60   usrp2::tx_metadata metadata;
61   metadata.timestamp = -1;
62   metadata.send_now = 1;
63   metadata.start_of_burst = 1;
64
65   bool ok = d_u2->tx_32fc(0, // FIXME: someday, streams will have channel numbers
66                           in, noutput_items, &metadata);
67   if (!ok){
68     std::cerr << "usrp2_sink_32fc: tx_32fc failed" << std::endl;
69     return -1;  // say we're done
70   }
71
72   return noutput_items;
73 }