Skip to content

Instantly share code, notes, and snippets.

@loganwashbourne
Created August 20, 2015 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loganwashbourne/6e1c1ef5e4cf1ff07e33 to your computer and use it in GitHub Desktop.
Save loganwashbourne/6e1c1ef5e4cf1ff07e33 to your computer and use it in GitHub Desktop.
/* -*- c++ -*- */
/*
* Copyright 2015 <+YOU OR YOUR COMPANY+>.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "Text_Sanitize_impl.h"
#include <pmt/pmt.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdio>
namespace gr {
namespace ACK {
Text_Sanitize::sptr
Text_Sanitize::make(char* message)
{
return gnuradio::get_initial_sptr
(new Text_Sanitize_impl(message));
}
void
Text_Sanitize_impl::print_message(pmt::pmt_t d_message)
{
pmt::print(d_message);
}
/*
void
Text_Sanitize_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
{
ninput_items_required[0] = noutput_items;
}
*/
int
Text_Sanitize_impl::general_work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const int *in = (int *) input_items[0];
pmt::pmt_t *out = (pmt::pmt_t *) output_items[0];
d_out_msg = pmt::string_to_symbol(d_message);
//for(int i = 0; i<strlen(d_message); i++)
//{
// pmt::vector_set(d_out_msg,i,d_message[i]);
//}
// Do <+signal processing+>
// Tell runtime system how many input items we consumed on
// each input stream.
consume_each (noutput_items);
// Tell runtime system how many output items we produced.
return noutput_items;
}
/*
* The private constructor
*/
Text_Sanitize_impl::Text_Sanitize_impl(char* message)
: gr::block("Text_Sanitize",
gr::io_signature::make(1, 1, sizeof(int)),
gr::io_signature::make(1, 1, sizeof(pmt::pmt_t))),
d_out_msg(pmt::string_to_symbol(std::string(""))),
d_message(message)
{
message_port_register_out(pmt::mp("print_message"));
set_msg_handler(pmt::mp("print"), boost::bind(&Text_Sanitize_impl::print_message, this, _1));
}
/*
* Our virtual destructor.
*/
Text_Sanitize_impl::~Text_Sanitize_impl()
{
}
} /* namespace ACK */
} /* namespace gr */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment