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_16sc.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_16sc(const std::string &ifc, const std::string &mac_addr)
37 throw (std::runtime_error)
39 return gnuradio::get_initial_sptr(new usrp2_sink_16sc(ifc, mac_addr));
42 usrp2_sink_16sc::usrp2_sink_16sc(const std::string &ifc, const std::string &mac_addr)
43 throw (std::runtime_error)
44 : usrp2_sink_base("usrp2_sink_16sc",
45 gr_make_io_signature(1, 1, sizeof(std::complex<int16_t>)),
51 usrp2_sink_16sc::~usrp2_sink_16sc()
57 usrp2_sink_16sc::work(int noutput_items,
58 gr_vector_const_void_star &input_items,
59 gr_vector_void_star &output_items)
61 std::complex<int16_t> *in = (std::complex<int16_t> *)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;
70 metadata.timestamp = -1;
71 metadata.send_now = 1;
72 metadata.start_of_burst = 1;
74 bool ok = d_u2->tx_16sc(0, // FIXME: someday, streams will have channel numbers
75 in, noutput_items, &metadata);
77 std::cerr << "usrp2_sink_16sc: tx_16sc failed" << std::endl;
78 return -1; // say we're done