Advertisement
Guest User

GNURadio no setup_rpc call, MWE c++ implementation

a guest
Mar 2nd, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.29 KB | None | 0 0
  1. /* -*- c++ -*- */
  2. /*
  3.  * Copyright 2016 <+YOU OR YOUR COMPANY+>.
  4.  *
  5.  * This is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 3, or (at your option)
  8.  * any later version.
  9.  *
  10.  * This software is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this software; see the file COPYING.  If not, write to
  17.  * the Free Software Foundation, Inc., 51 Franklin Street,
  18.  * Boston, MA 02110-1301, USA.
  19.  */
  20.  
  21. #ifdef HAVE_CONFIG_H
  22. #include "config.h"
  23. #endif
  24.  
  25. #include <gnuradio/io_signature.h>
  26. #include "cptest_impl.h"
  27.  
  28. namespace gr {
  29.   namespace ccsds {
  30.  
  31.     cptest::sptr
  32.     cptest::make()
  33.     {
  34.       return gnuradio::get_initial_sptr(new cptest_impl());
  35.     }
  36.  
  37.     /*
  38.      * The private constructor
  39.      */
  40.     cptest_impl::cptest_impl()
  41.       : gr::sync_block("cptest",
  42.               gr::io_signature::make(0, 0, 0),
  43.               gr::io_signature::make(0, 0, 0))
  44.     {
  45.       printf("constructor()\n");
  46.  
  47.       // register input
  48.       message_port_register_in(pmt::mp("in"));
  49.       set_msg_handler(pmt::mp("in"), boost::bind(&cptest_impl::process_frame, this, _1));
  50.     }
  51.  
  52.     void cptest_impl::process_frame(pmt::pmt_t msg_in) {
  53.       printf("process frame()\n");
  54.     }
  55.  
  56.     /*
  57.      * Our virtual destructor.
  58.      */
  59.     cptest_impl::~cptest_impl() { }
  60.  
  61.     int cptest_impl::work(int noutput_items,
  62.         gr_vector_const_void_star &input_items,
  63.         gr_vector_void_star &output_items)
  64.     {
  65.       // Do nothing here and return 0 samples processed
  66.       return 0;
  67.     }
  68.  
  69.     void cptest_impl::setup_rpc()
  70.     {
  71.       printf("setup_rpc()\n");
  72.       #ifdef GR_CTRLPORT
  73.     add_rpc_variable(
  74.         rpcbasic_sptr(new rpcbasic_register_get<cptest, float>(
  75.         alias(), "testval",
  76.         &cptest::get_testf,
  77.         pmt::mp(-2.0f), pmt::mp(2.0f), pmt::mp(0.0f),
  78.         "1", "Test value", RPC_PRIVLVL_MIN,
  79.         DISPTIME | DISPOPTSTRIP))
  80.     );
  81.       #endif
  82.     }
  83.   } /* namespace ccsds */
  84. } /* namespace gr */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement