root / gnuradio-core / src / lib / general / gr_scrambler_bb.cc @ fe2e6f80
History | View | Annotate | Download (1.7 kB)
| 1 | c4763fb9 | jcorgan | /* -*- c++ -*- */
|
|---|---|---|---|
| 2 | c4763fb9 | jcorgan | /*
|
| 3 | 0a9b999b | Eric Blossom | * Copyright 2008,2010 Free Software Foundation, Inc. |
| 4 | c4763fb9 | jcorgan | * |
| 5 | c4763fb9 | jcorgan | * This file is part of GNU Radio |
| 6 | c4763fb9 | jcorgan | * |
| 7 | c4763fb9 | jcorgan | * GNU Radio is free software; you can redistribute it and/or modify |
| 8 | c4763fb9 | jcorgan | * it under the terms of the GNU General Public License as published by |
| 9 | c4763fb9 | jcorgan | * the Free Software Foundation; either version 3, or (at your option) |
| 10 | c4763fb9 | jcorgan | * any later version. |
| 11 | c4763fb9 | jcorgan | * |
| 12 | c4763fb9 | jcorgan | * GNU Radio is distributed in the hope that it will be useful, |
| 13 | c4763fb9 | jcorgan | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | c4763fb9 | jcorgan | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | c4763fb9 | jcorgan | * GNU General Public License for more details. |
| 16 | c4763fb9 | jcorgan | * |
| 17 | c4763fb9 | jcorgan | * You should have received a copy of the GNU General Public License |
| 18 | c4763fb9 | jcorgan | * along with GNU Radio; see the file COPYING. If not, write to |
| 19 | c4763fb9 | jcorgan | * the Free Software Foundation, Inc., 51 Franklin Street, |
| 20 | c4763fb9 | jcorgan | * Boston, MA 02110-1301, USA. |
| 21 | c4763fb9 | jcorgan | */ |
| 22 | c4763fb9 | jcorgan | |
| 23 | c4763fb9 | jcorgan | #ifdef HAVE_CONFIG_H
|
| 24 | c4763fb9 | jcorgan | #include "config.h" |
| 25 | c4763fb9 | jcorgan | #endif
|
| 26 | c4763fb9 | jcorgan | |
| 27 | c4763fb9 | jcorgan | #include <gr_scrambler_bb.h> |
| 28 | c4763fb9 | jcorgan | #include <gr_io_signature.h> |
| 29 | c4763fb9 | jcorgan | |
| 30 | c4763fb9 | jcorgan | gr_scrambler_bb_sptr |
| 31 | c4763fb9 | jcorgan | gr_make_scrambler_bb(int mask, int seed, int len) |
| 32 | c4763fb9 | jcorgan | {
|
| 33 | 0a9b999b | Eric Blossom | return gnuradio::get_initial_sptr(new gr_scrambler_bb(mask, seed, len)); |
| 34 | c4763fb9 | jcorgan | } |
| 35 | c4763fb9 | jcorgan | |
| 36 | c4763fb9 | jcorgan | gr_scrambler_bb::gr_scrambler_bb(int mask, int seed, int len) |
| 37 | c4763fb9 | jcorgan | : gr_sync_block("scrambler_bb",
|
| 38 | c4763fb9 | jcorgan | gr_make_io_signature (1, 1, sizeof (unsigned char)), |
| 39 | c4763fb9 | jcorgan | gr_make_io_signature (1, 1, sizeof (unsigned char))), |
| 40 | c4763fb9 | jcorgan | d_lfsr(mask, seed, len) |
| 41 | c4763fb9 | jcorgan | {
|
| 42 | c4763fb9 | jcorgan | } |
| 43 | c4763fb9 | jcorgan | |
| 44 | c4763fb9 | jcorgan | int
|
| 45 | c4763fb9 | jcorgan | gr_scrambler_bb::work(int noutput_items,
|
| 46 | c4763fb9 | jcorgan | gr_vector_const_void_star &input_items, |
| 47 | c4763fb9 | jcorgan | gr_vector_void_star &output_items) |
| 48 | c4763fb9 | jcorgan | {
|
| 49 | c4763fb9 | jcorgan | const unsigned char *in = (const unsigned char *) input_items[0]; |
| 50 | c4763fb9 | jcorgan | unsigned char *out = (unsigned char *) output_items[0]; |
| 51 | c4763fb9 | jcorgan | |
| 52 | c4763fb9 | jcorgan | for (int i = 0; i < noutput_items; i++) |
| 53 | c4763fb9 | jcorgan | out[i] = d_lfsr.next_bit_scramble(in[i]); |
| 54 | c4763fb9 | jcorgan | |
| 55 | c4763fb9 | jcorgan | return noutput_items;
|
| 56 | c4763fb9 | jcorgan | } |