summaryrefslogtreecommitdiff
path: root/gr-digital
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital')
-rw-r--r--gr-digital/CMakeLists.txt2
-rw-r--r--gr-digital/grc/digital_correlate_access_code_tag_xx.xml (renamed from gr-digital/grc/digital_correlate_access_code_tag_bb.xml)23
-rw-r--r--gr-digital/grc/digital_costas_loop_cc.xml10
-rw-r--r--gr-digital/grc/variable_header_format_default.xml13
-rw-r--r--gr-digital/include/gnuradio/digital/CMakeLists.txt1
-rw-r--r--gr-digital/include/gnuradio/digital/correlate_access_code_tag_ff.h72
-rw-r--r--gr-digital/include/gnuradio/digital/header_format_counter.h1
-rw-r--r--gr-digital/include/gnuradio/digital/header_format_default.h10
-rw-r--r--gr-digital/lib/CMakeLists.txt5
-rw-r--r--gr-digital/lib/correlate_access_code_bb_impl.cc10
-rw-r--r--gr-digital/lib/correlate_access_code_bb_ts_impl.cc11
-rw-r--r--gr-digital/lib/correlate_access_code_ff_ts_impl.cc11
-rw-r--r--gr-digital/lib/correlate_access_code_tag_bb_impl.cc13
-rw-r--r--gr-digital/lib/correlate_access_code_tag_ff_impl.cc132
-rw-r--r--gr-digital/lib/correlate_access_code_tag_ff_impl.h61
-rw-r--r--gr-digital/lib/costas_loop_cc_impl.cc66
-rw-r--r--gr-digital/lib/header_format_counter.cc3
-rw-r--r--gr-digital/lib/header_format_default.cc10
-rwxr-xr-xgr-digital/python/digital/qa_correlate_access_code.py20
-rwxr-xr-xgr-digital/python/digital/qa_correlate_access_code_tag.py38
-rw-r--r--gr-digital/python/digital/qa_packet_format.py47
-rw-r--r--gr-digital/swig/digital_swig0.i3
22 files changed, 467 insertions, 95 deletions
diff --git a/gr-digital/CMakeLists.txt b/gr-digital/CMakeLists.txt
index c6fa0798d1..5edf96e8d5 100644
--- a/gr-digital/CMakeLists.txt
+++ b/gr-digital/CMakeLists.txt
@@ -34,8 +34,6 @@ GR_REGISTER_COMPONENT("gr-digital" ENABLE_GR_DIGITAL
ENABLE_GR_FILTER
ENABLE_GR_BLOCKS
ENABLE_GR_ANALOG
- ENABLE_GR_BLOCKS
- ENABLE_GR_FILTER
)
GR_SET_GLOBAL(GR_DIGITAL_INCLUDE_DIRS
diff --git a/gr-digital/grc/digital_correlate_access_code_tag_bb.xml b/gr-digital/grc/digital_correlate_access_code_tag_xx.xml
index 7d43f1b3f1..83ccb422ea 100644
--- a/gr-digital/grc/digital_correlate_access_code_tag_bb.xml
+++ b/gr-digital/grc/digital_correlate_access_code_tag_xx.xml
@@ -6,9 +6,24 @@
-->
<block>
<name>Correlate Access Code - Tag</name>
- <key>digital_correlate_access_code_tag_bb</key>
+ <key>digital_correlate_access_code_tag_xx</key>
<import>from gnuradio import digital</import>
- <make>digital.correlate_access_code_tag_bb($access_code, $threshold, $tagname)</make>
+ <make>digital.correlate_access_code_tag_$(type.fcn)($access_code, $threshold, $tagname)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:bb</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:ff</opt>
+ </option>
+ </param>
<param>
<name>Access Code</name>
<key>access_code</key>
@@ -27,10 +42,10 @@
</param>
<sink>
<name>in</name>
- <type>byte</type>
+ <type>$type</type>
</sink>
<source>
<name>out</name>
- <type>byte</type>
+ <type>$type</type>
</source>
</block>
diff --git a/gr-digital/grc/digital_costas_loop_cc.xml b/gr-digital/grc/digital_costas_loop_cc.xml
index 40db3a4a6f..23e3ca9037 100644
--- a/gr-digital/grc/digital_costas_loop_cc.xml
+++ b/gr-digital/grc/digital_costas_loop_cc.xml
@@ -61,4 +61,14 @@
<type>float</type>
<optional>1</optional>
</source>
+ <source>
+ <name>phase</name>
+ <type>float</type>
+ <optional>1</optional>
+ </source>
+ <source>
+ <name>error</name>
+ <type>float</type>
+ <optional>1</optional>
+ </source>
</block>
diff --git a/gr-digital/grc/variable_header_format_default.xml b/gr-digital/grc/variable_header_format_default.xml
index 55b361f8ca..88727600ed 100644
--- a/gr-digital/grc/variable_header_format_default.xml
+++ b/gr-digital/grc/variable_header_format_default.xml
@@ -10,12 +10,12 @@
<import>from gnuradio import digital</import>
<var_make>
#if int($access_code())==0 #
-self.$(id) = $(id) = digital.header_format_default(digital.packet_utils.default_access_code, $threshold)
+self.$(id) = $(id) = digital.header_format_default(digital.packet_utils.default_access_code, $threshold, $bps)
#else
-self.$(id) = $(id) = digital.header_format_default($access_code, $threshold)
+self.$(id) = $(id) = digital.header_format_default($access_code, $threshold, $bps)
#end if
</var_make>
- <var_value>digital.header_format_default($access_code, $threshold)</var_value>
+ <var_value>digital.header_format_default($access_code, $threshold, $bps)</var_value>
<make></make>
<param>
@@ -32,4 +32,11 @@ self.$(id) = $(id) = digital.header_format_default($access_code, $threshold)
<type>int</type>
</param>
+ <param>
+ <name>Payload Bits per Symbol</name>
+ <key>bps</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+
</block>
diff --git a/gr-digital/include/gnuradio/digital/CMakeLists.txt b/gr-digital/include/gnuradio/digital/CMakeLists.txt
index 1b22265853..911187cee5 100644
--- a/gr-digital/include/gnuradio/digital/CMakeLists.txt
+++ b/gr-digital/include/gnuradio/digital/CMakeLists.txt
@@ -46,6 +46,7 @@ install(FILES
corr_est_cc.h
correlate_access_code_bb.h
correlate_access_code_tag_bb.h
+ correlate_access_code_tag_ff.h
correlate_access_code_bb_ts.h
correlate_access_code_ff_ts.h
correlate_and_sync_cc.h
diff --git a/gr-digital/include/gnuradio/digital/correlate_access_code_tag_ff.h b/gr-digital/include/gnuradio/digital/correlate_access_code_tag_ff.h
new file mode 100644
index 0000000000..93e89d6a6e
--- /dev/null
+++ b/gr-digital/include/gnuradio/digital/correlate_access_code_tag_ff.h
@@ -0,0 +1,72 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2006,2011,2012,2017 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_DIGITAL_CORRELATE_ACCESS_CODE_TAG_FF_H
+#define INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_TAG_FF_H
+
+#include <gnuradio/digital/api.h>
+#include <gnuradio/sync_block.h>
+#include <string>
+
+namespace gr {
+ namespace digital {
+
+ /*!
+ * \brief Examine input for specified access code, one bit at a time.
+ * \ingroup packet_operators_blk
+ *
+ * \details
+ * input: stream of floats (generally, soft decisions)
+ * output: unaltered stream of bits (plus tags)
+ *
+ * This block annotates the input stream with tags. The tags have
+ * key name [tag_name], specified in the constructor. Used for
+ * searching an input data stream for preambles, etc., by slicing
+ * the soft decision symbol inputs.
+ */
+ class DIGITAL_API correlate_access_code_tag_ff : virtual public sync_block
+ {
+ public:
+ // gr::digital::correlate_access_code_tag_ff::sptr
+ typedef boost::shared_ptr<correlate_access_code_tag_ff> sptr;
+
+ /*!
+ * \param access_code is represented with 1 byte per bit,
+ * e.g., "010101010111000100"
+ * \param threshold maximum number of bits that may be wrong
+ * \param tag_name key of the tag inserted into the tag stream
+ */
+ static sptr make(const std::string &access_code,
+ int threshold,
+ const std::string &tag_name);
+
+ /*!
+ * \param access_code is represented with 1 byte per bit,
+ * e.g., "010101010111000100"
+ */
+ virtual bool set_access_code(const std::string &access_code) = 0;
+ };
+
+ } /* namespace digital */
+} /* namespace gr */
+
+#endif /* INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_TAG_FF_H */
diff --git a/gr-digital/include/gnuradio/digital/header_format_counter.h b/gr-digital/include/gnuradio/digital/header_format_counter.h
index 5eb075afb9..752a9ec775 100644
--- a/gr-digital/include/gnuradio/digital/header_format_counter.h
+++ b/gr-digital/include/gnuradio/digital/header_format_counter.h
@@ -112,7 +112,6 @@ namespace gr {
protected:
uint16_t d_counter; //!< keeps track of the number of packets transmitted
- uint16_t d_bps; //!< bits/sec of payload modulation
//! Verify that the header is valid
bool header_ok();
diff --git a/gr-digital/include/gnuradio/digital/header_format_default.h b/gr-digital/include/gnuradio/digital/header_format_default.h
index 4abd7bb2db..bfea3567f8 100644
--- a/gr-digital/include/gnuradio/digital/header_format_default.h
+++ b/gr-digital/include/gnuradio/digital/header_format_default.h
@@ -82,7 +82,8 @@ namespace gr {
: public header_format_base
{
public:
- header_format_default(const std::string &access_code, int threshold);
+ header_format_default(const std::string &access_code, int threshold,
+ int bps);
virtual ~header_format_default();
/*!
@@ -179,13 +180,18 @@ namespace gr {
* receiver. Can be up to 64-bits long.
* \param threshold How many bits can be wrong in the access
* code and still count as correct.
+ * \param bps The number of bits/second used in the payload's
+ * modulator.
*/
- static sptr make(const std::string &access_code, int threshold);
+ static sptr make(const std::string &access_code, int threshold,
+ int bps = 1);
protected:
uint64_t d_access_code; //!< register to hold the access code
size_t d_access_code_len; //!< length in bits of the access code
+ uint16_t d_bps; //!< bits/sec of payload modulation
+
unsigned long long d_data_reg; //!< used to look for access_code
unsigned long long d_mask; /*!< masks access_code bits (top N bits are set where
N is the number of bits in the access code) */
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt
index 84f53ec4f3..9df6808d1c 100644
--- a/gr-digital/lib/CMakeLists.txt
+++ b/gr-digital/lib/CMakeLists.txt
@@ -29,12 +29,10 @@ include_directories(
${GR_BLOCKS_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
${VOLK_INCLUDE_DIRS}
- ${LOG4CPP_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
link_directories(${Boost_LIBRARY_DIRS})
-link_directories(${LOG4CPP_LIBRARY_DIRS})
if(ENABLE_GR_CTRLPORT)
ADD_DEFINITIONS(-DGR_CTRLPORT)
@@ -64,6 +62,7 @@ list(APPEND digital_sources
corr_est_cc_impl.cc
correlate_access_code_bb_impl.cc
correlate_access_code_tag_bb_impl.cc
+ correlate_access_code_tag_ff_impl.cc
correlate_access_code_bb_ts_impl.cc
correlate_access_code_ff_ts_impl.cc
correlate_and_sync_cc_impl.cc
@@ -151,7 +150,6 @@ list(APPEND digital_libs
gnuradio-analog
${VOLK_LIBRARIES}
${Boost_LIBRARIES}
- ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-digital SHARED ${digital_sources})
@@ -228,7 +226,6 @@ if(ENABLE_TESTING)
gnuradio-digital
${Boost_LIBRARIES}
${CPPUNIT_LIBRARIES}
- ${LOG4CPP_LIBRARIES}
)
GR_ADD_TEST(test_gr_digital test-gr-digital)
diff --git a/gr-digital/lib/correlate_access_code_bb_impl.cc b/gr-digital/lib/correlate_access_code_bb_impl.cc
index 532871a407..a01eb6a2b5 100644
--- a/gr-digital/lib/correlate_access_code_bb_impl.cc
+++ b/gr-digital/lib/correlate_access_code_bb_impl.cc
@@ -27,14 +27,13 @@
#include "correlate_access_code_bb_impl.h"
#include <gnuradio/io_signature.h>
#include <gnuradio/blocks/count_bits.h>
+#include <boost/format.hpp>
#include <stdexcept>
#include <cstdio>
namespace gr {
namespace digital {
-#define VERBOSE 0
-
correlate_access_code_bb::sptr
correlate_access_code_bb::make(const std::string &access_code, int threshold)
{
@@ -51,6 +50,7 @@ namespace gr {
d_threshold(threshold)
{
if(!set_access_code(access_code)) {
+ GR_LOG_ERROR(d_logger, "access_code is > 64 bits");
throw std::out_of_range ("access_code is > 64 bits");
}
}
@@ -109,14 +109,12 @@ namespace gr {
// test for access code with up to threshold errors
new_flag = (nwrong <= d_threshold);
-#if VERBOSE
if(new_flag) {
- fprintf(stderr, "access code found: %llx\n", d_access_code);
+ GR_LOG_DEBUG(d_logger, boost::format("access code found: %llx") % d_access_code);
}
else {
- fprintf(stderr, "%llx ==> %llx\n", d_access_code, d_data_reg);
+ GR_LOG_DEBUG(d_logger, boost::format("%llx ==> %llx") % d_access_code % d_data_reg);
}
-#endif
// shift in new data and new flag
d_data_reg = (d_data_reg << 1) | (in[i] & 0x1);
diff --git a/gr-digital/lib/correlate_access_code_bb_ts_impl.cc b/gr-digital/lib/correlate_access_code_bb_ts_impl.cc
index e2fe37d8bb..91b57feac3 100644
--- a/gr-digital/lib/correlate_access_code_bb_ts_impl.cc
+++ b/gr-digital/lib/correlate_access_code_bb_ts_impl.cc
@@ -26,6 +26,7 @@
#include "correlate_access_code_bb_ts_impl.h"
#include <gnuradio/io_signature.h>
+#include <boost/format.hpp>
#include <stdexcept>
#include <volk/volk.h>
#include <cstdio>
@@ -34,8 +35,6 @@
namespace gr {
namespace digital {
-#define VERBOSE 0
-
correlate_access_code_bb_ts::sptr
correlate_access_code_bb_ts::make(const std::string &access_code,
int threshold,
@@ -58,6 +57,7 @@ namespace gr {
set_tag_propagation_policy(TPP_DONT);
if(!set_access_code(access_code)) {
+ GR_LOG_ERROR(d_logger, "access_code is > 64 bits");
throw std::out_of_range ("access_code is > 64 bits");
}
@@ -91,10 +91,9 @@ namespace gr {
for(unsigned i=0; i < d_len; i++){
d_access_code = (d_access_code << 1) | (access_code[i] & 1);
}
- if(VERBOSE) {
- std::cerr << "Access code: " << std::hex << d_access_code << std::dec << std::endl;
- std::cerr << "Mask: " << std::hex << d_mask << std::dec << std::endl;
- }
+
+ GR_LOG_DEBUG(d_logger, boost::format("Access code: %llx") % d_access_code);
+ GR_LOG_DEBUG(d_logger, boost::format("Mask: %llx") % d_mask);
return true;
}
diff --git a/gr-digital/lib/correlate_access_code_ff_ts_impl.cc b/gr-digital/lib/correlate_access_code_ff_ts_impl.cc
index dfbac40505..21ff3fbda0 100644
--- a/gr-digital/lib/correlate_access_code_ff_ts_impl.cc
+++ b/gr-digital/lib/correlate_access_code_ff_ts_impl.cc
@@ -27,6 +27,7 @@
#include "correlate_access_code_ff_ts_impl.h"
#include <gnuradio/io_signature.h>
#include <gnuradio/math.h>
+#include <boost/format.hpp>
#include <stdexcept>
#include <volk/volk.h>
#include <cstdio>
@@ -35,8 +36,6 @@
namespace gr {
namespace digital {
-#define VERBOSE 0
-
correlate_access_code_ff_ts::sptr
correlate_access_code_ff_ts::make(const std::string &access_code,
int threshold,
@@ -58,6 +57,7 @@ namespace gr {
set_tag_propagation_policy(TPP_DONT);
if(!set_access_code(access_code)) {
+ GR_LOG_ERROR(d_logger, "access_code is > 64 bits");
throw std::out_of_range ("access_code is > 64 bits");
}
@@ -91,10 +91,9 @@ namespace gr {
for(unsigned i=0; i < d_len; i++){
d_access_code = (d_access_code << 1) | (access_code[i] & 1);
}
- if(VERBOSE) {
- std::cerr << "Access code: " << std::hex << d_access_code << std::dec << std::endl;
- std::cerr << "Mask: " << std::hex << d_mask << std::dec << std::endl;
- }
+
+ GR_LOG_DEBUG(d_logger, boost::format("Access code: %llx") % d_access_code);
+ GR_LOG_DEBUG(d_logger, boost::format("Mask: %llx") % d_mask);
return true;
}
diff --git a/gr-digital/lib/correlate_access_code_tag_bb_impl.cc b/gr-digital/lib/correlate_access_code_tag_bb_impl.cc
index de2e1a06c3..753efa7a51 100644
--- a/gr-digital/lib/correlate_access_code_tag_bb_impl.cc
+++ b/gr-digital/lib/correlate_access_code_tag_bb_impl.cc
@@ -26,6 +26,7 @@
#include "correlate_access_code_tag_bb_impl.h"
#include <gnuradio/io_signature.h>
+#include <boost/format.hpp>
#include <stdexcept>
#include <volk/volk.h>
#include <cstdio>
@@ -34,8 +35,6 @@
namespace gr {
namespace digital {
-#define VERBOSE 0
-
correlate_access_code_tag_bb::sptr
correlate_access_code_tag_bb::make(const std::string &access_code,
int threshold,
@@ -56,6 +55,7 @@ namespace gr {
d_threshold(threshold), d_len(0)
{
if(!set_access_code(access_code)) {
+ GR_LOG_ERROR(d_logger, "access_code is > 64 bits");
throw std::out_of_range ("access_code is > 64 bits");
}
@@ -85,10 +85,8 @@ namespace gr {
d_access_code = (d_access_code << 1) | (access_code[i] & 1);
}
- if(VERBOSE) {
- std::cerr << "Access code: " << std::hex << d_access_code << std::dec << std::endl;
- std::cerr << "Mask: " << std::hex << d_mask << std::dec << std::endl;
- }
+ GR_LOG_DEBUG(d_logger, boost::format("Access code: %llx") % d_access_code);
+ GR_LOG_DEBUG(d_logger, boost::format("Mask: %llx") % d_mask);
return true;
}
@@ -116,8 +114,7 @@ namespace gr {
// shift in new data
d_data_reg = (d_data_reg << 1) | (in[i] & 0x1);
if(nwrong <= d_threshold) {
- if(VERBOSE)
- std::cerr << "writing tag at sample " << abs_out_sample_cnt + i << std::endl;
+ GR_LOG_DEBUG(d_logger, boost::format("writing tag at sample %llu") % (abs_out_sample_cnt + i));
add_item_tag(0, //stream ID
abs_out_sample_cnt + i, //sample
d_key, //frame info
diff --git a/gr-digital/lib/correlate_access_code_tag_ff_impl.cc b/gr-digital/lib/correlate_access_code_tag_ff_impl.cc
new file mode 100644
index 0000000000..6efacbb08b
--- /dev/null
+++ b/gr-digital/lib/correlate_access_code_tag_ff_impl.cc
@@ -0,0 +1,132 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2010-2012,2017 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 "correlate_access_code_tag_ff_impl.h"
+#include <gnuradio/io_signature.h>
+#include <gnuradio/math.h>
+#include <boost/format.hpp>
+#include <stdexcept>
+#include <volk/volk.h>
+#include <cstdio>
+#include <iostream>
+
+namespace gr {
+ namespace digital {
+
+ correlate_access_code_tag_ff::sptr
+ correlate_access_code_tag_ff::make(const std::string &access_code,
+ int threshold,
+ const std::string &tag_name)
+ {
+ return gnuradio::get_initial_sptr
+ (new correlate_access_code_tag_ff_impl(access_code,
+ threshold, tag_name));
+ }
+
+
+ correlate_access_code_tag_ff_impl::correlate_access_code_tag_ff_impl(
+ const std::string &access_code, int threshold, const std::string &tag_name)
+ : sync_block("correlate_access_code_tag_ff",
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(1, 1, sizeof(float))),
+ d_data_reg(0), d_mask(0),
+ d_threshold(threshold), d_len(0)
+ {
+ if(!set_access_code(access_code)) {
+ GR_LOG_ERROR(d_logger, "access_code is > 64 bits");
+ throw std::out_of_range ("access_code is > 64 bits");
+ }
+
+ std::stringstream str;
+ str << name() << unique_id();
+ d_me = pmt::string_to_symbol(str.str());
+ d_key = pmt::string_to_symbol(tag_name);
+ }
+
+ correlate_access_code_tag_ff_impl::~correlate_access_code_tag_ff_impl()
+ {
+ }
+
+ bool
+ correlate_access_code_tag_ff_impl::set_access_code(
+ const std::string &access_code)
+ {
+ d_len = access_code.length(); // # of bytes in string
+ if(d_len > 64)
+ return false;
+
+ // set len bottom bits to 1.
+ d_mask = ((~0ULL) >> (64 - d_len));
+
+ d_access_code = 0;
+ for(unsigned i=0; i < d_len; i++){
+ d_access_code = (d_access_code << 1) | (access_code[i] & 1);
+ }
+
+ GR_LOG_DEBUG(d_logger, boost::format("Access code: %llx") % d_access_code);
+ GR_LOG_DEBUG(d_logger, boost::format("Mask: %llx") % d_mask);
+
+ return true;
+ }
+
+ int
+ correlate_access_code_tag_ff_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *in = (const float*)input_items[0];
+ float *out = (float*)output_items[0];
+
+ uint64_t abs_out_sample_cnt = nitems_written(0);
+
+ for(int i = 0; i < noutput_items; i++) {
+ out[i] = in[i];
+
+ // compute hamming distance between desired access code and current data
+ uint64_t wrong_bits = 0;
+ uint64_t nwrong = d_threshold+1;
+
+ wrong_bits = (d_data_reg ^ d_access_code) & d_mask;
+ volk_64u_popcnt(&nwrong, wrong_bits);
+
+ // shift in new data
+ d_data_reg = (d_data_reg << 1) | (gr::branchless_binary_slicer(in[i]) & 0x1);
+ if(nwrong <= d_threshold) {
+ GR_LOG_DEBUG(d_logger, boost::format("writing tag at sample %llu") % (abs_out_sample_cnt + i));
+ add_item_tag(0, //stream ID
+ abs_out_sample_cnt + i, //sample
+ d_key, //frame info
+ pmt::from_long(nwrong), //data (number wrong)
+ d_me //block src id
+ );
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace digital */
+} /* namespace gr */
diff --git a/gr-digital/lib/correlate_access_code_tag_ff_impl.h b/gr-digital/lib/correlate_access_code_tag_ff_impl.h
new file mode 100644
index 0000000000..67d3ba2d6d
--- /dev/null
+++ b/gr-digital/lib/correlate_access_code_tag_ff_impl.h
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2006,2011,2012,2017 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_DIGITAL_CORRELATE_ACCESS_CODE_TAG_FF_IMPL_H
+#define INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_TAG_FF_IMPL_H
+
+#include <gnuradio/digital/correlate_access_code_tag_ff.h>
+
+namespace gr {
+ namespace digital {
+
+ class correlate_access_code_tag_ff_impl :
+ public correlate_access_code_tag_ff
+ {
+ private:
+ unsigned long long d_access_code; // access code to locate start of packet
+ // access code is left justified in the word
+ unsigned long long d_data_reg; // used to look for access_code
+ unsigned long long d_mask; // masks access_code bits (top N bits are set where
+ // N is the number of bits in the access code)
+ unsigned int d_threshold; // how many bits may be wrong in sync vector
+ unsigned int d_len; // the length of the access code
+
+ pmt::pmt_t d_key, d_me; //d_key is the tag name, d_me is the block name + unique ID
+
+ public:
+ correlate_access_code_tag_ff_impl(const std::string &access_code,
+ int threshold,
+ const std::string &tag_name);
+ ~correlate_access_code_tag_ff_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ bool set_access_code(const std::string &access_code);
+ };
+
+ } /* namespace digital */
+} /* namespace gr */
+
+#endif /* INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_TAG_FF_IMPL_H */
diff --git a/gr-digital/lib/costas_loop_cc_impl.cc b/gr-digital/lib/costas_loop_cc_impl.cc
index d29d95684a..edf0db33ef 100644
--- a/gr-digital/lib/costas_loop_cc_impl.cc
+++ b/gr-digital/lib/costas_loop_cc_impl.cc
@@ -41,10 +41,13 @@ namespace gr {
(new costas_loop_cc_impl(loop_bw, order, use_snr));
}
+ static int ios[] = { sizeof(gr_complex), sizeof(float), sizeof(float), sizeof(float) };
+ static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int));
+
costas_loop_cc_impl::costas_loop_cc_impl(float loop_bw, int order, bool use_snr)
: sync_block("costas_loop_cc",
io_signature::make(1, 1, sizeof(gr_complex)),
- io_signature::make2(1, 2, sizeof(gr_complex), sizeof(float))),
+ io_signature::makev(1, 4, iosig)),
blocks::control_loop(loop_bw, 1.0, -1.0),
d_order(order), d_error(0), d_noise(1.0), d_phase_detector(NULL)
{
@@ -180,9 +183,9 @@ namespace gr {
{
const gr_complex *iptr = (gr_complex *) input_items[0];
gr_complex *optr = (gr_complex *) output_items[0];
- float *foptr = (float *) output_items[1];
-
- bool write_foptr = output_items.size() >= 2;
+ float *freq_optr = output_items.size() >= 2 ? (float *) output_items[1] : NULL;
+ float *phase_optr = output_items.size() >= 3 ? (float *) output_items[2] : NULL;
+ float *error_optr = output_items.size() >= 4 ? (float *) output_items[3] : NULL;
gr_complex nco_out;
@@ -191,47 +194,30 @@ namespace gr {
nitems_read(0)+noutput_items,
pmt::intern("phase_est"));
- if(write_foptr) {
- for(int i = 0; i < noutput_items; i++) {
- if(tags.size() > 0) {
- if(tags[0].offset-nitems_read(0) == (size_t)i) {
- d_phase = (float)pmt::to_double(tags[0].value);
- tags.erase(tags.begin());
- }
+ for(int i = 0; i < noutput_items; i++) {
+ if(tags.size() > 0) {
+ if(tags[0].offset-nitems_read(0) == (size_t)i) {
+ d_phase = (float)pmt::to_double(tags[0].value);
+ tags.erase(tags.begin());
}
-
- nco_out = gr_expj(-d_phase);
- optr[i] = iptr[i] * nco_out;
-
- d_error = (*this.*d_phase_detector)(optr[i]);
- d_error = gr::branchless_clip(d_error, 1.0);
-
- advance_loop(d_error);
- phase_wrap();
- frequency_limit();
-
- foptr[i] = d_freq;
}
- }
- else {
- for(int i = 0; i < noutput_items; i++) {
- if(tags.size() > 0) {
- if(tags[0].offset-nitems_read(0) == (size_t)i) {
- d_phase = (float)pmt::to_double(tags[0].value);
- tags.erase(tags.begin());
- }
- }
- nco_out = gr_expj(-d_phase);
- optr[i] = iptr[i] * nco_out;
+ nco_out = gr_expj(-d_phase);
+ optr[i] = iptr[i] * nco_out;
- d_error = (*this.*d_phase_detector)(optr[i]);
- d_error = gr::branchless_clip(d_error, 1.0);
+ d_error = (*this.*d_phase_detector)(optr[i]);
+ d_error = gr::branchless_clip(d_error, 1.0);
- advance_loop(d_error);
- phase_wrap();
- frequency_limit();
- }
+ advance_loop(d_error);
+ phase_wrap();
+ frequency_limit();
+
+ if (freq_optr != NULL)
+ freq_optr[i] = d_freq;
+ if (phase_optr != NULL)
+ phase_optr[i] = d_phase;
+ if (error_optr != NULL)
+ error_optr[i] = d_error;
}
return noutput_items;
diff --git a/gr-digital/lib/header_format_counter.cc b/gr-digital/lib/header_format_counter.cc
index 6244ec1679..078d7d4be1 100644
--- a/gr-digital/lib/header_format_counter.cc
+++ b/gr-digital/lib/header_format_counter.cc
@@ -44,9 +44,8 @@ namespace gr {
header_format_counter::header_format_counter(const std::string &access_code,
int threshold, int bps)
- : header_format_default(access_code, threshold)
+ : header_format_default(access_code, threshold, bps)
{
- d_bps = bps;
d_counter = 0;
}
diff --git a/gr-digital/lib/header_format_default.cc b/gr-digital/lib/header_format_default.cc
index 1b7a60e17f..621a801729 100644
--- a/gr-digital/lib/header_format_default.cc
+++ b/gr-digital/lib/header_format_default.cc
@@ -34,16 +34,16 @@ namespace gr {
header_format_default::sptr
header_format_default::make(const std::string &access_code,
- int threshold)
+ int threshold, int bps)
{
return header_format_default::sptr
- (new header_format_default(access_code, threshold));
+ (new header_format_default(access_code, threshold, bps));
}
header_format_default::header_format_default(const std::string &access_code,
- int threshold)
+ int threshold, int bps)
: header_format_base(),
- d_data_reg(0), d_mask(0), d_threshold(0),
+ d_bps(bps), d_data_reg(0), d_mask(0), d_threshold(0),
d_pkt_len(0), d_pkt_count(0), d_nbits(0)
{
if(!set_access_code(access_code)) {
@@ -214,7 +214,7 @@ namespace gr {
d_info = pmt::make_dict();
d_info = pmt::dict_add(d_info, pmt::intern("payload symbols"),
- pmt::from_long(8*len));
+ pmt::from_long(8*len / d_bps));
return static_cast<int>(len);
}
diff --git a/gr-digital/python/digital/qa_correlate_access_code.py b/gr-digital/python/digital/qa_correlate_access_code.py
index d89b457117..0302e81313 100755
--- a/gr-digital/python/digital/qa_correlate_access_code.py
+++ b/gr-digital/python/digital/qa_correlate_access_code.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2006,2007,2010,2011,2013 Free Software Foundation, Inc.
+# Copyright 2006,2007,2010,2011,2013,2017 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -91,6 +91,24 @@ class test_correlate_access_code(gr_unittest.TestCase):
result_data = dst.data()
self.assertEqual(expected_result, result_data)
+ def test_004(self):
+ code = tuple(string_to_1_0_list(default_access_code))
+ access_code = to_1_0_string(code)
+ pad = (0,) * 64
+ #print code
+ #print access_code
+ src_bits = code + (1, 0, 1, 1) + pad
+ src_data = [2.0*x - 1.0 for x in src_bits]
+ expected_result_bits = code + (1, 0, 1, 1) + pad
+ expected_result = [2.0*x - 1.0 for x in expected_result_bits]
+ src = blocks.vector_source_f(src_data)
+ op = digital.correlate_access_code_tag_ff(access_code, 0, "test")
+ dst = blocks.vector_sink_f()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data, 5)
+
if __name__ == '__main__':
gr_unittest.run(test_correlate_access_code, "test_correlate_access_code.xml")
diff --git a/gr-digital/python/digital/qa_correlate_access_code_tag.py b/gr-digital/python/digital/qa_correlate_access_code_tag.py
index f2663e4ecc..378333c286 100755
--- a/gr-digital/python/digital/qa_correlate_access_code_tag.py
+++ b/gr-digital/python/digital/qa_correlate_access_code_tag.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2006,2007,2010,2011,2013 Free Software Foundation, Inc.
+# Copyright 2006,2007,2010,2011,2013,2017 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -50,7 +50,7 @@ class test_correlate_access_code(gr_unittest.TestCase):
src_data = (1, 0, 1, 1, 1, 1, 0, 1, 1) + pad + (0,) * 7
src = blocks.vector_source_b(src_data)
op = digital.correlate_access_code_tag_bb("1011", 0, "sync")
- dst = blocks.tag_debug(1, "sync")
+ dst = blocks.tag_debug(gr.sizeof_char, "sync")
self.tb.connect(src, op, dst)
self.tb.run()
result_data = dst.current_tags()
@@ -65,10 +65,40 @@ class test_correlate_access_code(gr_unittest.TestCase):
#print code
#print access_code
src_data = code + (1, 0, 1, 1) + pad
- expected_result = pad + code + (3, 0, 1, 1)
src = blocks.vector_source_b(src_data)
op = digital.correlate_access_code_tag_bb(access_code, 0, "sync")
- dst = blocks.tag_debug(1, "sync")
+ dst = blocks.tag_debug(gr.sizeof_char, "sync")
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = dst.current_tags()
+ self.assertEqual(len(result_data), 1)
+ self.assertEqual(result_data[0].offset, len(code))
+
+ def test_003(self):
+ pad = (0,) * 64
+ src_bits = (1, 0, 1, 1, 1, 1, 0, 1, 1) + pad + (0,) * 7
+ src_data = [2.0*x - 1.0 for x in src_bits]
+ src = blocks.vector_source_f(src_data)
+ op = digital.correlate_access_code_tag_ff("1011", 0, "sync")
+ dst = blocks.tag_debug(gr.sizeof_float, "sync")
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = dst.current_tags()
+ self.assertEqual(len(result_data), 2)
+ self.assertEqual(result_data[0].offset, 4)
+ self.assertEqual(result_data[1].offset, 9)
+
+ def test_004(self):
+ code = tuple(string_to_1_0_list(default_access_code))
+ access_code = to_1_0_string(code)
+ pad = (0,) * 64
+ #print code
+ #print access_code
+ src_bits = code + (1, 0, 1, 1) + pad
+ src_data = [2.0*x - 1.0 for x in src_bits]
+ src = blocks.vector_source_f(src_data)
+ op = digital.correlate_access_code_tag_ff(access_code, 0, "sync")
+ dst = blocks.tag_debug(gr.sizeof_float, "sync")
self.tb.connect(src, op, dst)
self.tb.run()
result_data = dst.current_tags()
diff --git a/gr-digital/python/digital/qa_packet_format.py b/gr-digital/python/digital/qa_packet_format.py
index 6440b80a5e..ae1a79f1f4 100644
--- a/gr-digital/python/digital/qa_packet_format.py
+++ b/gr-digital/python/digital/qa_packet_format.py
@@ -20,7 +20,7 @@
# Boston, MA 02110-1301, USA.
#
-import random, time, struct
+import time, struct
import pmt
from gnuradio import gr, gr_unittest, digital, blocks
from gnuradio.digital import packet_utils
@@ -80,6 +80,51 @@ class test_packet_format_fb(gr_unittest.TestCase):
self.assertEqual(send_str, payload[0:length])
+ def test_packet_parse_default(self):
+ ac = packet_utils.default_access_code
+ length = '0000000000000001'
+
+ hdr_format_1bps = digital.header_format_default(ac, 0)
+ hdr_format_4bps = digital.header_format_default(ac, 0, 4)
+
+ ac_bits = [int(x) & 1 for x in ac]
+ length_bits = [int(x) & 1 for x in length]
+ header_bits = ac_bits + length_bits + length_bits
+
+ src_hdr = blocks.vector_source_b(header_bits)
+
+ parser_1bps = digital.protocol_parser_b(hdr_format_1bps)
+ parser_4bps = digital.protocol_parser_b(hdr_format_4bps)
+
+ snk_hdr_1bps = blocks.message_debug()
+ snk_hdr_4bps = blocks.message_debug()
+
+ self.tb.connect(src_hdr, parser_1bps)
+ self.tb.connect(src_hdr, parser_4bps)
+
+ self.tb.msg_connect(parser_1bps, 'info', snk_hdr_1bps, 'store')
+ self.tb.msg_connect(parser_4bps, 'info', snk_hdr_4bps, 'store')
+
+ self.tb.start()
+ while (snk_hdr_1bps.num_messages() < 1) and (snk_hdr_4bps.num_messages() < 1):
+ time.sleep(0.1)
+ self.tb.stop()
+ self.tb.wait()
+
+ result_1bps = snk_hdr_1bps.get_message(0)
+ result_4bps = snk_hdr_4bps.get_message(0)
+
+ self.assertTrue(pmt.dict_has_key(
+ result_1bps, pmt.intern('payload symbols')))
+ self.assertEqual(pmt.to_long(pmt.dict_ref(
+ result_1bps, pmt.intern('payload symbols'), pmt.PMT_F)), 8)
+
+ self.assertTrue(pmt.dict_has_key(
+ result_4bps, pmt.intern('payload symbols')))
+ self.assertEqual(pmt.to_long(pmt.dict_ref(
+ result_4bps, pmt.intern('payload symbols'), pmt.PMT_F)), 2)
+
+
def test_packet_format_async_counter(self):
bps = 2
ac = packet_utils.default_access_code
diff --git a/gr-digital/swig/digital_swig0.i b/gr-digital/swig/digital_swig0.i
index 753d0267b9..0f0652f5ae 100644
--- a/gr-digital/swig/digital_swig0.i
+++ b/gr-digital/swig/digital_swig0.i
@@ -46,6 +46,7 @@
#include "gnuradio/digital/corr_est_cc.h"
#include "gnuradio/digital/correlate_access_code_bb.h"
#include "gnuradio/digital/correlate_access_code_tag_bb.h"
+#include "gnuradio/digital/correlate_access_code_tag_ff.h"
#include "gnuradio/digital/correlate_access_code_bb_ts.h"
#include "gnuradio/digital/correlate_access_code_ff_ts.h"
#include "gnuradio/digital/correlate_and_sync_cc.h"
@@ -81,6 +82,7 @@
%include "gnuradio/digital/corr_est_cc.h"
%include "gnuradio/digital/correlate_access_code_bb.h"
%include "gnuradio/digital/correlate_access_code_tag_bb.h"
+%include "gnuradio/digital/correlate_access_code_tag_ff.h"
%include "gnuradio/digital/correlate_access_code_bb_ts.h"
%include "gnuradio/digital/correlate_access_code_ff_ts.h"
%include "gnuradio/digital/correlate_and_sync_cc.h"
@@ -114,6 +116,7 @@ GR_SWIG_BLOCK_MAGIC2(digital, constellation_soft_decoder_cf);
GR_SWIG_BLOCK_MAGIC2(digital, corr_est_cc);
GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_bb);
GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_tag_bb);
+GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_tag_ff);
GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_bb_ts);
GR_SWIG_BLOCK_MAGIC2(digital, correlate_access_code_ff_ts);
GR_SWIG_BLOCK_MAGIC2(digital, correlate_and_sync_cc);