3 * Copyright 2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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.
27 #include <usrp2_sink_32fc.h>
28 #include <usrp2/metadata.h>
29 #include <gr_io_signature.h>
32 // FIXME hack until VRT replaces libusrp2
33 #define U2_MIN_SAMPLES 9
36 usrp2_make_sink_32fc(const std::string &ifc, const std::string &mac_addr)
37 throw (std::runtime_error)
39 return gnuradio::get_initial_sptr(new usrp2_sink_32fc(ifc, mac_addr));
42 usrp2_sink_32fc::usrp2_sink_32fc(const std::string &ifc, const std::string &mac_addr)
43 throw (std::runtime_error)
44 : usrp2_sink_base("usrp2_sink_32fc",
45 gr_make_io_signature(1, 1, sizeof(gr_complex)),
51 usrp2_sink_32fc::~usrp2_sink_32fc()
57 usrp2_sink_32fc::work(int noutput_items,
58 gr_vector_const_void_star &input_items,
59 gr_vector_void_star &output_items)
61 gr_complex *in = (gr_complex *)input_items[0];
63 // FIXME: Current libusrp2 can't handle short packets.
64 // Returning 0 assumes there will be more samples
66 if (noutput_items < U2_MIN_SAMPLES)
69 usrp2::tx_metadata metadata;
71 // Set TX metadata to either start time or now
72 if (d_should_wait == true) {
73 metadata.timestamp = d_tx_time;
74 metadata.send_now = 0;
75 d_should_wait = false;
78 metadata.timestamp = -1;
79 metadata.send_now = 1;
81 metadata.start_of_burst = 1;
83 bool ok = d_u2->tx_32fc(0, in, noutput_items, &metadata);
85 std::cerr << "usrp2_sink_32fc: tx_32fc failed" << std::endl;
86 return -1; // say we're done