[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9560 - in gnuradio/branches/developers/jcorgan/scr/gn
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r9560 - in gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src: lib/general python/gnuradio/gr |
Date: |
Thu, 11 Sep 2008 20:27:38 -0600 (MDT) |
Author: jcorgan
Date: 2008-09-11 20:27:38 -0600 (Thu, 11 Sep 2008)
New Revision: 9560
Added:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.cc
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.h
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.i
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.cc
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.h
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.i
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py
Modified:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/Makefile.am
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/general.i
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/qa_gri_lfsr.cc
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/python/gnuradio/gr/Makefile.am
Log:
Added gr.scrambler_bb and gr.descrambler_bb blocks.
Modified:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/Makefile.am
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/Makefile.am
2008-09-12 01:20:29 UTC (rev 9559)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/Makefile.am
2008-09-12 02:27:38 UTC (rev 9560)
@@ -163,7 +163,9 @@
gri_short_to_float.cc \
gri_uchar_to_float.cc \
malloc16.c \
- gr_unpack_k_bits_bb.cc
+ gr_unpack_k_bits_bb.cc \
+ gr_descrambler_bb.cc \
+ gr_scrambler_bb.cc
libgeneral_qa_la_SOURCES = \
qa_general.cc \
@@ -320,7 +322,9 @@
gri_uchar_to_float.h \
malloc16.h \
random.h \
- gr_unpack_k_bits_bb.h
+ gr_unpack_k_bits_bb.h \
+ gr_descrambler_bb.h \
+ gr_scrambler_bb.h
noinst_HEADERS = \
@@ -448,7 +452,9 @@
gri_agc_cc.i \
gri_agc_ff.i \
gri_agc2_cc.i \
- gri_agc2_ff.i
+ gri_agc2_ff.i \
+ gr_descrambler_bb.i \
+ gr_scrambler_bb.i
CLEANFILES = $(BUILT_SOURCES) *.pyc
Modified:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/general.i
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/general.i
2008-09-12 01:20:29 UTC (rev 9559)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/general.i
2008-09-12 02:27:38 UTC (rev 9560)
@@ -129,6 +129,8 @@
#include <gr_cpfsk_bc.h>
#include <gr_encode_ccsds_27_bb.h>
#include <gr_decode_ccsds_27_fb.h>
+#include <gr_descrambler_bb.h>
+#include <gr_scrambler_bb.h>
%}
%include "gr_nop.i"
@@ -238,3 +240,5 @@
%include "gr_cpfsk_bc.i"
%include "gr_encode_ccsds_27_bb.i"
%include "gr_decode_ccsds_27_fb.i"
+%include "gr_descrambler_bb.i"
+%include "gr_scrambler_bb.i"
Added:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.cc
(rev 0)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.cc
2008-09-12 02:27:38 UTC (rev 9560)
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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_descrambler_bb.h>
+#include <gr_io_signature.h>
+
+gr_descrambler_bb_sptr
+gr_make_descrambler_bb(int mask, int seed, int len)
+{
+ return gr_descrambler_bb_sptr(new gr_descrambler_bb(mask, seed, len));
+}
+
+gr_descrambler_bb::gr_descrambler_bb(int mask, int seed, int len)
+ : gr_sync_block("descrambler_bb",
+ gr_make_io_signature (1, 1, sizeof (unsigned char)),
+ gr_make_io_signature (1, 1, sizeof (unsigned char))),
+ d_lfsr(mask, seed, len)
+{
+}
+
+int
+gr_descrambler_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] = d_lfsr.next_bit_descramble(in[i]);
+
+ return noutput_items;
+}
Added:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.h
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.h
(rev 0)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.h
2008-09-12 02:27:38 UTC (rev 9560)
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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_DESCRAMBLER_BB_H
+#define INCLUDED_GR_DESCRAMBLER_BB_H
+
+#include <gr_sync_block.h>
+#include "gri_lfsr.h"
+
+class gr_descrambler_bb;
+typedef boost::shared_ptr<gr_descrambler_bb> gr_descrambler_bb_sptr;
+
+gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len);
+
+/*!
+ * \brief Descramble an input stream using an LFSR
+ *
+ * \param mask Polynomial mask for LFSR
+ * \param seed Initial shift register contents
+ * \param len Shift register length
+ *
+ * \ingroup misc
+ */
+
+class gr_descrambler_bb : public gr_sync_block
+{
+ friend gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int
len);
+
+ gri_lfsr d_lfsr;
+
+ gr_descrambler_bb(int mask, int seed, int len);
+
+public:
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_GR_DESCRAMBLER_BB_H */
Added:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.i
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.i
(rev 0)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_descrambler_bb.i
2008-09-12 02:27:38 UTC (rev 9560)
@@ -0,0 +1,31 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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,descrambler_bb);
+
+gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len);
+
+class gr_descrambler_bb : public gr_sync_block
+{
+private:
+ gr_descrambler_bb(int mask, int seed, int len);
+};
Added:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.cc
(rev 0)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.cc
2008-09-12 02:27:38 UTC (rev 9560)
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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_scrambler_bb.h>
+#include <gr_io_signature.h>
+
+gr_scrambler_bb_sptr
+gr_make_scrambler_bb(int mask, int seed, int len)
+{
+ return gr_scrambler_bb_sptr(new gr_scrambler_bb(mask, seed, len));
+}
+
+gr_scrambler_bb::gr_scrambler_bb(int mask, int seed, int len)
+ : gr_sync_block("scrambler_bb",
+ gr_make_io_signature (1, 1, sizeof (unsigned char)),
+ gr_make_io_signature (1, 1, sizeof (unsigned char))),
+ d_lfsr(mask, seed, len)
+{
+}
+
+int
+gr_scrambler_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] = d_lfsr.next_bit_scramble(in[i]);
+
+ return noutput_items;
+}
Added:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.h
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.h
(rev 0)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.h
2008-09-12 02:27:38 UTC (rev 9560)
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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_SCRAMBLER_BB_H
+#define INCLUDED_GR_SCRAMBLER_BB_H
+
+#include <gr_sync_block.h>
+#include "gri_lfsr.h"
+
+class gr_scrambler_bb;
+typedef boost::shared_ptr<gr_scrambler_bb> gr_scrambler_bb_sptr;
+
+gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len);
+
+/*!
+ * \brief Scramble an input stream using an LFSR
+ *
+ * \param mask Polynomial mask for LFSR
+ * \param seed Initial shift register contents
+ * \param len Shift register length
+ *
+ * \ingroup misc
+ */
+
+class gr_scrambler_bb : public gr_sync_block
+{
+ friend gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int
len);
+
+ gri_lfsr d_lfsr;
+
+ gr_scrambler_bb(int mask, int seed, int len);
+
+public:
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_GR_SCRAMBLER_BB_H */
Added:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.i
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.i
(rev 0)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/gr_scrambler_bb.i
2008-09-12 02:27:38 UTC (rev 9560)
@@ -0,0 +1,31 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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,scrambler_bb);
+
+gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len);
+
+class gr_scrambler_bb : public gr_sync_block
+{
+private:
+ gr_scrambler_bb(int mask, int seed, int len);
+};
Modified:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/qa_gri_lfsr.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/qa_gri_lfsr.cc
2008-09-12 01:20:29 UTC (rev 9559)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/lib/general/qa_gri_lfsr.cc
2008-09-12 02:27:38 UTC (rev 9560)
@@ -101,7 +101,7 @@
qa_gri_lfsr::test_descrambler()
{
// CCSDS 7-bit scrambler
- int mask = 0x8A; // 1+x^4+X^6
+ int mask = 0x8A;
int seed = 0x7F;
int length = 7;
Modified:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/python/gnuradio/gr/Makefile.am
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/python/gnuradio/gr/Makefile.am
2008-09-12 01:20:29 UTC (rev 9559)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/python/gnuradio/gr/Makefile.am
2008-09-12 02:27:38 UTC (rev 9560)
@@ -92,6 +92,5 @@
qa_single_pole_iir_cc.py \
qa_skiphead.py \
qa_unpack_k_bits.py \
- qa_repeat.py
-
-CLEANFILES = *.pyc
+ qa_repeat.py \
+ qa_scrambler.py
Added:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py
===================================================================
---
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py
(rev 0)
+++
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py
2008-09-12 02:27:38 UTC (rev 9560)
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 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.
+#
+
+from gnuradio import gr, gr_unittest
+
+class test_scrambler(gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_scrambler_descrambler(self):
+ src_data = (1,)*1000
+ src = gr.vector_source_b(src_data, False)
+ scrambler = gr.scrambler_bb(0x8a, 0x7F, 7) # CCSDS 7-bit scrambler
+ descrambler = gr.descrambler_bb(0x8a, 0x7F, 7)
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, scrambler, descrambler, dst)
+ self.tb.run()
+ self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage
during synchronization
+
+if __name__ == '__main__':
+ gr_unittest.main ()
Property changes on:
gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py
___________________________________________________________________
Name: svn:executable
+ *
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9560 - in gnuradio/branches/developers/jcorgan/scr/gnuradio-core/src: lib/general python/gnuradio/gr,
jcorgan <=