summaryrefslogtreecommitdiff
path: root/gr-digital/python
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/python')
-rw-r--r--gr-digital/python/Makefile.am12
-rw-r--r--gr-digital/python/crc.py37
-rw-r--r--gr-digital/python/qa_crc32.py60
3 files changed, 104 insertions, 5 deletions
diff --git a/gr-digital/python/Makefile.am b/gr-digital/python/Makefile.am
index a6d9f779d1..09be67f3a5 100644
--- a/gr-digital/python/Makefile.am
+++ b/gr-digital/python/Makefile.am
@@ -40,18 +40,20 @@ noinst_PYTHON = \
qa_constellation_decoder_cb.py \
qa_correlate_access_code.py \
qa_costas_loop_cc.py \
+ qa_crc32.py \
qa_lms_equalizer.py
digital_PYTHON = \
__init__.py \
- psk.py \
+ crc.py \
+ bpsk.py \
dbpsk.py \
dqpsk.py \
d8psk.py \
- psk2.py \
generic_mod_demod.py \
+ gmsk.py \
+ psk.py \
+ psk2.py \
qam.py \
- bpsk.py \
- qpsk.py \
- gmsk.py
+ qpsk.py
endif
diff --git a/gr-digital/python/crc.py b/gr-digital/python/crc.py
new file mode 100644
index 0000000000..f9d369f4cb
--- /dev/null
+++ b/gr-digital/python/crc.py
@@ -0,0 +1,37 @@
+#
+# Copyright 2005,2007,2011 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, gru
+import struct
+
+def gen_and_append_crc32(s):
+ crc = gr.crc32(s)
+ return s + struct.pack(">I", gru.hexint(crc) & 0xFFFFFFFF)
+
+def check_crc32(s):
+ if len(s) < 4:
+ return (False, '')
+ msg = s[:-4]
+ #print "msg = '%s'" % (msg,)
+ actual = gr.crc32(msg)
+ (expected,) = struct.unpack(">I", s[-4:])
+ # print "actual =", hex(actual), "expected =", hex(expected)
+ return (actual == expected, msg)
diff --git a/gr-digital/python/qa_crc32.py b/gr-digital/python/qa_crc32.py
new file mode 100644
index 0000000000..f86813f3f3
--- /dev/null
+++ b/gr-digital/python/qa_crc32.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#
+# Copyright 2011 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
+import digital_swig
+import random, cmath
+
+class test_crc32(gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test01 (self):
+ data = 100*"0"
+ expected_result = 2943744955
+ result = digital_swig.crc32(data)
+ #print hex(result)
+
+ self.assertEqual (expected_result, result)
+
+ def test02 (self):
+ data = 100*"1"
+ expected_result = 2326594156
+ result = digital_swig.crc32(data)
+ #print hex(result)
+
+ self.assertEqual (expected_result, result)
+
+ def test03 (self):
+ data = 10*"0123456789"
+ expected_result = 3774345973
+ result = digital_swig.crc32(data)
+ #print hex(result)
+
+ self.assertEqual (expected_result, result)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_crc32, "test_crc32.xml")