3 * Copyright 2005,2010 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 <gr_fake_channel_coder_pp.h>
28 #include <gr_io_signature.h>
33 static const int PAD_VAL = 0xAA;
35 gr_fake_channel_encoder_pp_sptr
36 gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen)
38 return gnuradio::get_initial_sptr(new gr_fake_channel_encoder_pp(input_vlen,
42 gr_fake_channel_encoder_pp::gr_fake_channel_encoder_pp(int input_vlen, int output_vlen)
43 : gr_sync_block("fake_channel_encoder_pp",
44 gr_make_io_signature(1, 1, input_vlen * sizeof(unsigned char)),
45 gr_make_io_signature(1, 1, output_vlen * sizeof(unsigned char))),
46 d_input_vlen(input_vlen), d_output_vlen(output_vlen)
48 if (input_vlen <= 0 || output_vlen <= 0 || input_vlen > output_vlen)
49 throw std::invalid_argument("gr_fake_channel_encoder_pp");
52 gr_fake_channel_encoder_pp::~gr_fake_channel_encoder_pp()
57 gr_fake_channel_encoder_pp::work (int noutput_items,
58 gr_vector_const_void_star &input_items,
59 gr_vector_void_star &output_items)
61 const unsigned char *in = (const unsigned char *) input_items[0];
62 unsigned char *out = (unsigned char *) output_items[0];
63 int npad = d_output_vlen - d_input_vlen;
65 for (int i = 0; i < noutput_items; i++){
66 memcpy(out, in, d_input_vlen);
67 memset(out + d_input_vlen, PAD_VAL, npad);
75 // ------------------------------------------------------------------------
77 gr_fake_channel_decoder_pp_sptr
78 gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen)
80 return gnuradio::get_initial_sptr(new gr_fake_channel_decoder_pp(input_vlen,
84 gr_fake_channel_decoder_pp::gr_fake_channel_decoder_pp(int input_vlen, int output_vlen)
85 : gr_sync_block("fake_channel_decoder_pp",
86 gr_make_io_signature(1, 1, input_vlen * sizeof(unsigned char)),
87 gr_make_io_signature(1, 1, output_vlen * sizeof(unsigned char))),
88 d_input_vlen(input_vlen), d_output_vlen(output_vlen)
90 if (input_vlen <= 0 || output_vlen <= 0 || output_vlen > input_vlen)
91 throw std::invalid_argument("gr_fake_channel_decoder_pp");
94 gr_fake_channel_decoder_pp::~gr_fake_channel_decoder_pp()
99 gr_fake_channel_decoder_pp::work (int noutput_items,
100 gr_vector_const_void_star &input_items,
101 gr_vector_void_star &output_items)
103 const unsigned char *in = (const unsigned char *) input_items[0];
104 unsigned char *out = (unsigned char *) output_items[0];
106 for (int i = 0; i < noutput_items; i++){
107 memcpy(out, in, d_output_vlen);
109 out += d_output_vlen;
112 return noutput_items;