Skip to content

Commit

Permalink
Block Modifications:
Browse files Browse the repository at this point in the history
 digital.mpsk_receiver_cc: Set reasonable default parameter values for GRC definition
 digital.ofdm_insert_preamble: Expose enter_preamble() as public, to allow external state changes
                               Cleanup of incorrect forecast behavior
                               Make the flag port optional, incase external preamble triggers are preferred to in-band
 gr_vector_source: added set_data( data ) and rewind() public methods
 gr_head: added set_length(int) method to modify head length

New Blocks Added:
 gr_keep_m_in_n: Allows periodic extraction of M items instead of 1 (in keep_1_in_n)
 gr_pack_k_bits: Complementary block fo gr_unpack_k_bits
 gr_vector_insert_x: Complement to the gr_head block, inserts a vector into a stream then becomes a pass through
  • Loading branch information
osh committed Jun 6, 2012
1 parent 0eeb875 commit f2ab263
Show file tree
Hide file tree
Showing 26 changed files with 831 additions and 9 deletions.
2 changes: 2 additions & 0 deletions gnuradio-core/src/lib/general/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ set(gr_core_general_triple_threats
gr_interleaved_short_to_complex
gr_iqcomp_cc
gr_keep_one_in_n
gr_keep_m_in_n
gr_kludge_copy
gr_lfsr_32k_source_s
gr_map_bb
Expand Down Expand Up @@ -285,6 +286,7 @@ set(gr_core_general_triple_threats
gr_vector_to_stream
gr_vector_to_streams
gr_unpack_k_bits_bb
gr_pack_k_bits_bb
gr_descrambler_bb
gr_scrambler_bb
gr_probe_density_b
Expand Down
4 changes: 4 additions & 0 deletions gnuradio-core/src/lib/general/general.i
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <gr_stream_to_vector.h>
#include <gr_vector_to_stream.h>
#include <gr_keep_one_in_n.h>
#include <gr_keep_m_in_n.h>
#include <gr_fft_vcc.h>
#include <gr_fft_vfc.h>
#include <gr_float_to_int.h>
Expand Down Expand Up @@ -100,6 +101,7 @@
#include <gr_test_types.h>
#include <gr_test.h>
#include <gr_unpack_k_bits_bb.h>
#include <gr_pack_k_bits_bb.h>
#include <gr_diff_phasor_cc.h>
#include <gr_diff_encoder_bb.h>
#include <gr_diff_decoder_bb.h>
Expand Down Expand Up @@ -155,6 +157,7 @@
%include "gr_stream_to_vector.i"
%include "gr_vector_to_stream.i"
%include "gr_keep_one_in_n.i"
%include "gr_keep_m_in_n.i"
%include "gr_fft_vcc.i"
%include "gr_fft_vfc.i"
%include "gr_float_to_int.i"
Expand Down Expand Up @@ -218,6 +221,7 @@
%include "gr_test_types.h"
%include "gr_test.i"
%include "gr_unpack_k_bits_bb.i"
%include "gr_pack_k_bits_bb.i"
%include "gr_diff_phasor_cc.i"
%include "gr_diff_encoder_bb.i"
%include "gr_diff_decoder_bb.i"
Expand Down
1 change: 1 addition & 0 deletions gnuradio-core/src/lib/general/gr_head.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class GR_CORE_API gr_head : public gr_sync_block
gr_vector_void_star &output_items);

void reset() { d_ncopied_items = 0; }
void set_length(int nitems) { d_nitems = nitems; }
};

GR_CORE_API gr_head_sptr
Expand Down
1 change: 1 addition & 0 deletions gnuradio-core/src/lib/general/gr_head.i
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ class gr_head : public gr_block {
gr_head();
public:
void reset();
void set_length(int nitems);
};

85 changes: 85 additions & 0 deletions gnuradio-core/src/lib/general/gr_keep_m_in_n.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* -*- c++ -*- */
/*
* Copyright 2004,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio 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.
*
* GNU Radio 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 GNU Radio; 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 <gr_keep_m_in_n.h>
#include <gr_io_signature.h>
#include <string.h>
#include <stdio.h>

gr_keep_m_in_n_sptr
gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset)
{
return gnuradio::get_initial_sptr(new gr_keep_m_in_n (item_size, m, n, offset));
}


/*
*
* offset = 0, starts with 0th item
* offset = 1, starts with 1st item, etc...
*
* we take m items out of each n
*/
gr_keep_m_in_n::gr_keep_m_in_n (size_t item_size, int m, int n, int offset)
: gr_sync_block ("keep_m_in_n",
gr_make_io_signature (1, 1, n*item_size),
gr_make_io_signature (1, 1, m*item_size)),
d_n(n),
d_m(m),
d_offset( offset )
{
// sanity checking
assert(d_m > 0);
assert(d_n > 0);
assert(d_m <= d_n);
assert(d_offset <= (d_n-d_m));
}


void gr_keep_m_in_n::set_offset(int offset){
d_offset = offset;
}


int
gr_keep_m_in_n::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
uint8_t* out = (uint8_t*) output_items[0];
const uint8_t* in = (const uint8_t*) input_items[0];

int in_item( input_signature()->sizeof_stream_item(0) );
int out_item( output_signature()->sizeof_stream_item(0) );
int single_size = in_item/d_n;

// iterate over data blocks of size {n, input : m, output}
for(int i=0; i<noutput_items; i++){
memcpy( &out[out_item*i], &in[in_item*i + single_size*d_offset], out_item);
}

return noutput_items;
}
62 changes: 62 additions & 0 deletions gnuradio-core/src/lib/general/gr_keep_m_in_n.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* -*- c++ -*- */
/*
* Copyright 2004 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio 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.
*
* GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/

#ifndef INCLUDED_GR_KEEP_M_IN_N_H
#define INCLUDED_GR_KEEP_M_IN_N_H

#include <gr_core_api.h>
#include <gr_sync_block.h>

class gr_keep_m_in_n;
typedef boost::shared_ptr<gr_keep_m_in_n> gr_keep_m_in_n_sptr;

GR_CORE_API gr_keep_m_in_n_sptr
gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset);


/*!
* \brief decimate a stream, keeping one item out of every n.
* \ingroup slicedice_blk
*/
class GR_CORE_API gr_keep_m_in_n : public gr_sync_block
{
friend GR_CORE_API gr_keep_m_in_n_sptr
gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset);

int d_n;
int d_m;
int d_count;
int d_offset;

protected:
gr_keep_m_in_n (size_t item_size, int m, int n, int offset);

public:
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);

void set_offset(int offset);

};

#endif /* INCLUDED_GR_KEEP_M_IN_N_H */
35 changes: 35 additions & 0 deletions gnuradio-core/src/lib/general/gr_keep_m_in_n.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* -*- c++ -*- */
/*
* Copyright 2004 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio 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.
*
* GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/

GR_SWIG_BLOCK_MAGIC(gr,keep_m_in_n)

gr_keep_m_in_n_sptr
gr_make_keep_m_in_n (size_t itemsize, int m, int n, int offset);

class gr_keep_m_in_n : public gr_sync_block
{
protected:
gr_keep_m_in_n (size_t itemsize, int m, int n, int offset);
public:
void set_offset(int offset);

};
69 changes: 69 additions & 0 deletions gnuradio-core/src/lib/general/gr_pack_k_bits_bb.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* -*- c++ -*- */
/*
* Copyright 2005,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio 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.
*
* GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/

#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <gr_pack_k_bits_bb.h>
#include <gr_io_signature.h>
#include <stdexcept>
#include <iostream>

gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k)
{
return gnuradio::get_initial_sptr(new gr_pack_k_bits_bb (k));
}


gr_pack_k_bits_bb::gr_pack_k_bits_bb (unsigned k)
: gr_sync_decimator ("pack_k_bits_bb",
gr_make_io_signature (1, 1, sizeof (unsigned char)),
gr_make_io_signature (1, 1, sizeof (unsigned char)),
k),
d_k (k)
{
if (d_k == 0)
throw std::out_of_range ("interpolation must be > 0");
}

gr_pack_k_bits_bb::~gr_pack_k_bits_bb ()
{
}

int
gr_pack_k_bits_bb::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const unsigned char *in = (const unsigned char *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];

for (int i = 0; i < noutput_items; i++){
out[i] = 0x00;
for (unsigned int j = 0; j < d_k; j++){
out[i] |= (0x01 & in[i*d_k+j])<<j;
}
}

return noutput_items;
}
56 changes: 56 additions & 0 deletions gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* -*- c++ -*- */
/*
* Copyright 2006 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio 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.
*
* GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/

#ifndef INCLUDED_GR_PACK_K_BITS_BB_H
#define INCLUDED_GR_PACK_K_BITS_BB_H

#include <gr_core_api.h>
#include <gr_sync_decimator.h>

class gr_pack_k_bits_bb;
typedef boost::shared_ptr<gr_pack_k_bits_bb> gr_pack_k_bits_bb_sptr;
GR_CORE_API gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k);

class gr_pack_k_bits_bb;

/*!
* \brief Converts a byte with k relevent bits to k output bytes with 1 bit in the LSB.
* \ingroup converter_blk
*/
class GR_CORE_API gr_pack_k_bits_bb : public gr_sync_decimator
{
private:
friend GR_CORE_API gr_pack_k_bits_bb_sptr gr_make_pack_k_bits_bb (unsigned k);

gr_pack_k_bits_bb (unsigned k);

unsigned d_k; // number of relevent bits to pack from k input bytes

public:
~gr_pack_k_bits_bb ();

int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};

#endif

0 comments on commit f2ab263

Please sign in to comment.