GNU Radio 3.3.0 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2008 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_RX_16SC_HANDLER_H 00024 #define INCLUDED_RX_16SC_HANDLER_H 00025 00026 #include <usrp2/rx_nop_handler.h> 00027 #include <usrp2/copiers.h> 00028 00029 class rx_16sc_handler : public usrp2::rx_nop_handler 00030 { 00031 std::complex<int16_t> *d_dest; 00032 00033 // Private constructor 00034 rx_16sc_handler(uint64_t max_samples, uint64_t max_quantum, std::complex<int16_t> *dest) 00035 : rx_nop_handler(max_samples, max_quantum), d_dest(dest) {} 00036 00037 public: 00038 // Shared pointer to one of these 00039 typedef boost::shared_ptr<rx_16sc_handler> sptr; 00040 00041 // Factory function to return a shared pointer to a new instance 00042 static sptr make(uint64_t max_samples, uint64_t max_quantum, std::complex<int16_t> *dest) 00043 { 00044 return sptr(new rx_16sc_handler(max_samples, max_quantum, dest)); 00045 } 00046 00047 // Invoked by USRP2 API when samples are available 00048 bool operator()(const uint32_t *items, size_t nitems, const usrp2::rx_metadata *metadata) 00049 { 00050 // Copy/reformat/endian swap USRP2 data to destination buffer 00051 usrp2::copy_u2_16sc_to_host_16sc(nitems, items, d_dest); 00052 d_dest += nitems; 00053 00054 // FIXME: do something with metadata 00055 00056 // Call parent to determine if there is room to be called again 00057 return rx_nop_handler::operator()(items, nitems, metadata); 00058 } 00059 00060 ~rx_16sc_handler(); 00061 }; 00062 00063 #endif /* INCLUDED_RX_16SC_HANDLER_H */