diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index 55f59ab..a5c9a01 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -6,7 +6,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later # install(FILES - UTAT_HERON_heron_rx_bb.block.yml UTAT_HERON_header_format_esttc.block.yml UTAT_HERON_esttc_framer.block.yml UTAT_HERON_esttc_deframer.block.yml diff --git a/grc/UTAT_HERON_heron_rx_bb.block.yml b/grc/UTAT_HERON_heron_rx_bb.block.yml deleted file mode 100644 index 55e6689..0000000 --- a/grc/UTAT_HERON_heron_rx_bb.block.yml +++ /dev/null @@ -1,17 +0,0 @@ -id: UTAT_HERON_heron_rx_bb -label: HERON RX BB -category: '[UTAT]/Deprecated' -flags: '[ deprecated ]' - -templates: - imports: from gnuradio import UTAT_HERON - make: UTAT_HERON.heron_rx_bb() -inputs: -- label: in - domain: stream - dtype: byte -outputs: -- label: out - domain: stream - dtype: byte -file_format: 1 diff --git a/include/gnuradio/UTAT_HERON/CMakeLists.txt b/include/gnuradio/UTAT_HERON/CMakeLists.txt index 67a833d..849255a 100644 --- a/include/gnuradio/UTAT_HERON/CMakeLists.txt +++ b/include/gnuradio/UTAT_HERON/CMakeLists.txt @@ -11,7 +11,6 @@ ######################################################################## install(FILES api.h - heron_rx_bb.h header_format_esttc.h esttc_framer.h esttc_deframer.h diff --git a/include/gnuradio/UTAT_HERON/heron_rx_bb.h b/include/gnuradio/UTAT_HERON/heron_rx_bb.h deleted file mode 100644 index 6478629..0000000 --- a/include/gnuradio/UTAT_HERON/heron_rx_bb.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2023 Universitys of Toronto Aerospace Team. - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#ifndef INCLUDED_UTAT_HERON_HERON_RX_BB_H -#define INCLUDED_UTAT_HERON_HERON_RX_BB_H - -#include -#include - -namespace gr { -namespace UTAT_HERON { - -/*! - * \brief Only allow ESTTC packet payloads to pass - * \ingroup UTAT_HERON - * - * \deprecated Replaced with UTAT_HERON::esttc_deframer - */ -class UTAT_HERON_API heron_rx_bb : virtual public gr::block -{ -public: - typedef std::shared_ptr sptr; - - /*! - * \brief Return a shared_ptr to a new instance of UTAT_HERON::heron_rx_bb. - * - * To avoid accidental use of raw pointers, UTAT_HERON::heron_rx_bb's - * constructor is in a private implementation - * class. UTAT_HERON::heron_rx_bb::make is the public interface for - * creating new instances. - */ - static sptr make(); -}; - -} -} - -#endif diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 6ee09e5..4b38cc8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -11,17 +11,10 @@ ######################################################################## include(GrPlatform) #define LIB_SUFFIX list(APPEND UTAT_HERON_sources - utils/heron_packet_manager.cc - utils/heron_packet_manager.h - utils/heron_packet.h - utils/debug_logger.cc - utils/debug_logger.h utils/pdu_lambda.h utils/pdu_lambda.cc utils/common.h utils/common.cc - heron_rx_bb_impl.cc - heron_rx_bb_impl.h header_format_esttc.cc esttc_framer_impl.cc esttc_deframer_impl.cc diff --git a/lib/heron_rx_bb_impl.cc b/lib/heron_rx_bb_impl.cc deleted file mode 100644 index b769d50..0000000 --- a/lib/heron_rx_bb_impl.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2023 University of Toronto Aerospace Team. - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#include "heron_rx_bb_impl.h" -#include "utils/debug_logger.h" -#include -#include -#include - -namespace gr { -namespace UTAT_HERON { - -using input_type = uint8_t; -using output_type = uint8_t; - -heron_rx_bb::sptr heron_rx_bb::make() -{ - return gnuradio::make_block_sptr(); -} - -heron_rx_bb_impl::heron_rx_bb_impl() - : gr::block( - "heron_rx_bb", - gr::io_signature::make(1, 1, sizeof(input_type)), - gr::io_signature::make(1, 1, sizeof(output_type))) -{ - #ifdef DEBUG_LOGGER - debug_logger << "starting debug at time = " << std::time(0) << '\n'; - debug_logger << "running constructor\n"; - debug_logger << std::hex; - std::cout << "running constructor, debug: " << DEBUG_FILE << '\n'; - #endif -} - -heron_rx_bb_impl::~heron_rx_bb_impl(){ - DEBUG_STREAM("running destructor\n"); -} - -void heron_rx_bb_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required) -{ - DEBUG_STREAM("running forecast\n"); - - float data_len = 128.f/2; // how big data field 2 is expeceted to be in bytes - float dec_per_packet = 9.f; // dec = decoration = prefix + suffix (in bytes) - float packet_len = data_len + dec_per_packet; - float npackets = noutput_items / (data_len+1); // add 1 for extra carrige return - - ninput_items_required[0] = static_cast(8*npackets*packet_len); -} - -int heron_rx_bb_impl::general_work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) -{ - auto in = static_cast(input_items[0]); - auto out = static_cast(output_items[0]); - - DEBUG_STREAM(std::dec); - DEBUG_STREAM("running general work with noutput_items = " << noutput_items << '\n'); - DEBUG_STREAM(std::hex); - - const int ninput_max = ninput_items[0]; - const int noutput_max = noutput_items; - - int ninput = 0; // number of bytes actually processed - int noutput = 0; // number of bytes actually outputted - // NOTE: ninput is actually counting bits processed, - // since data coming into the block should be unpacked - // (every byte only carries a single bit) - - auto fill_output_buf_if_able = [&](){ - while(d_pkt.data_available() && noutput < noutput_max){ - out[noutput] = d_pkt.pop_data(); - noutput++; - } - }; - - fill_output_buf_if_able(); - - while(ninput < ninput_max && noutput < noutput_max){ - d_pkt.process_bit(in[ninput]); - ninput++; - fill_output_buf_if_able(); - } - - consume_each(ninput); - return noutput; - -} - -} -} diff --git a/lib/heron_rx_bb_impl.h b/lib/heron_rx_bb_impl.h deleted file mode 100644 index 91150ed..0000000 --- a/lib/heron_rx_bb_impl.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2023 University of Toronto Aerospace Team. - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#ifndef INCLUDED_UTAT_HERON_HERON_RX_BB_IMPL_H -#define INCLUDED_UTAT_HERON_HERON_RX_BB_IMPL_H - -#include "utils/heron_packet_manager.h" -#include -#include - -namespace gr { -namespace UTAT_HERON { - -class heron_rx_bb_impl : public heron_rx_bb -{ -private: - heron_packet_manager d_pkt; -public: - heron_rx_bb_impl(); - ~heron_rx_bb_impl(); - void forecast(int noutput_items, gr_vector_int& ninput_items_required); - int general_work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); -}; - -} -} - -#endif diff --git a/lib/utils/debug_logger.cc b/lib/utils/debug_logger.cc deleted file mode 100644 index 4f8db90..0000000 --- a/lib/utils/debug_logger.cc +++ /dev/null @@ -1,7 +0,0 @@ -#include "debug_logger.h" - -#ifdef DEBUG_LOGGER - -std::ofstream debug_logger(DEBUG_FILE, std::ios_base::out); - -#endif \ No newline at end of file diff --git a/lib/utils/debug_logger.h b/lib/utils/debug_logger.h deleted file mode 100644 index cc0b669..0000000 --- a/lib/utils/debug_logger.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef INCLUDED_DEBUG_LOGGER_H -#define INCLUDED_DEBUG_LOGGER_H - -#ifndef DEBUG_FILE -#define DEBUG_STREAM(x) -#else - -#include - -#define DEBUG_LOGGER -extern std::ofstream debug_logger; -#define DEBUG_STREAM(x) debug_logger << x - -#endif - -#endif \ No newline at end of file diff --git a/lib/utils/heron_packet.h b/lib/utils/heron_packet.h deleted file mode 100644 index 29d095f..0000000 --- a/lib/utils/heron_packet.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef INCLUDED_HERON_PACKET_H -#define INCLUDED_HERON_PACKET_H - -#include -#include - -struct heron_packet{ - uint32_t preamble; - uint8_t sync_word; - uint8_t size_byte; - std::deque data; - uint16_t checksum; -}; - -#endif \ No newline at end of file diff --git a/lib/utils/heron_packet_manager.cc b/lib/utils/heron_packet_manager.cc deleted file mode 100644 index cdbcf73..0000000 --- a/lib/utils/heron_packet_manager.cc +++ /dev/null @@ -1,298 +0,0 @@ -#include "heron_packet_manager.h" -#include "debug_logger.h" -#include -#include - -heron_packet_manager::heron_packet_manager(){ - move_to_getting_preamble(); -} - - -bool heron_packet_manager::preamble_identified() const{ - return (packet.preamble & 0xFFFFFFFF) == 0xAAAAAAAA; -} -bool heron_packet_manager::sync_word_identified() const{ - return (packet.sync_word & 0xFF) == 0x7E; -} -bool heron_packet_manager::size_byte_identified() const{ - return counter == 8; -} -bool heron_packet_manager::data_identified() const{ - return counter == 8*packet.size_byte; -} -bool heron_packet_manager::checksum_identified() const{ - return counter == 16; -} - - -void heron_packet_manager::move_to_getting_preamble(){ - - packet.preamble = 0x00000000; - packet.sync_word = 0x00; - packet.size_byte = 0x00; - packet.data.clear(); - packet.checksum = 0x0000; - - state = getting_preamble; -} -void heron_packet_manager::move_to_getting_sync_word(){ - state = getting_sync_word; - counter = 0; -} -void heron_packet_manager::move_to_getting_size_byte(){ - state = getting_size_byte; - counter = 0; -} -void heron_packet_manager::move_to_getting_data(){ - state = getting_data; - counter = 0; -} -void heron_packet_manager::move_to_getting_checksum(){ - state = getting_checksum; - counter = 0; -} -void heron_packet_manager::notify_data_available(){ - state = finished_packet; -} - -template -void heron_packet_manager::append_bit(uint8_t bit, T& data){ - if (bit == 0x01) { - data = (data << 1) + 1; - } else if (bit == 0x00) { - data = data << 1; - }else{ - throw std::runtime_error("!!! Don't use Pack K Bits before this block, must be 0x00 or 0x01 input !!!"); - } -} - -void heron_packet_manager::append_bit_to_preamble(uint8_t bit){ - append_bit(bit, packet.preamble); -} -void heron_packet_manager::append_bit_to_sync_word(uint8_t bit){ - append_bit(bit, packet.sync_word); - counter++; -} -void heron_packet_manager::append_bit_to_size_byte(uint8_t bit){ - append_bit(bit, packet.size_byte); - counter++; -} -void heron_packet_manager::append_bit_to_data(uint8_t bit){ - if (counter % 8 == 0) { - packet.data.push_back(0x00); - } - int byte_idx = (int)(counter/8); // Floor counter/8 - append_bit(bit, packet.data[byte_idx]); - counter++; -} -void heron_packet_manager::append_bit_to_checksum(uint8_t bit){ - append_bit(bit, packet.checksum); - counter++; -} - -uint8_t heron_packet_manager::pop_data(){ - uint8_t ret = packet.data.front(); - packet.data.pop_front(); - if(packet.data.empty()) move_to_getting_preamble(); - return ret; -} - -bool heron_packet_manager::data_available(){ - return state == finished_packet; -} - -uint16_t -heron_packet_manager::crc16() const -{ - // Uses the "CRC16/CCITT-FALSE implementation from https://crccalc.com - uint16_t poly = 0x1021; - uint16_t data_byte = 0x0000; - uint16_t crc = 0xFFFF; - - /* calculate value with data_length as input */ - data_byte = packet.size_byte; - data_byte <<= 8; - for(int i=0; i<8; i++) { - uint16_t xor_flag = (crc ^ data_byte) & 0x8000; - crc <<= 1; - if(xor_flag) { - crc ^= poly; - } - data_byte <<= 1; - } - - /* calculate crc value for the rest of the datafields */ - for(size_t i=0; i < packet.data.size(); i++){ - data_byte = packet.data[i]; - data_byte <<= 8; - for(int i=0; i<8; i++) { - uint16_t xor_flag = (crc ^ data_byte) & 0x8000; - crc <<= 1; - if(xor_flag) { - crc ^= poly; - } - data_byte <<= 1; - } - } - - /* return crc_value */ - return crc; -} - -bool heron_packet_manager::checksum_matches() const{ - return crc16() == packet.checksum; -} - -void heron_packet_manager::process_bit(uint8_t bit){ - - switch (state) { - - case getting_preamble: - process_preamble_bit(bit); - break; - - case getting_sync_word: - process_sync_word_bit(bit); - break; - - case getting_size_byte: - process_size_byte_bit(bit); - break; - - case getting_data: - process_data_bit(bit); - break; - - case getting_checksum: - process_checksum_bit(bit); - break; - - case finished_packet: - throw std::runtime_error("packet is ready! please read it before processing new bits"); - - } -} - -void heron_packet_manager::process_preamble_bit(uint8_t bit){ - append_bit_to_preamble(bit); - debug_log_getting_preamble(); - if (preamble_identified()) { - move_to_getting_sync_word(); - debug_log_finished_preamble(); - } -} - -void heron_packet_manager::process_sync_word_bit(uint8_t bit){ - append_bit_to_sync_word(bit); - debug_log_getting_sync_word(); - if(sync_word_identified()){ - move_to_getting_size_byte(); - debug_log_finished_sync_word(); - }else if(sync_word_timeout()){ - debug_log_sync_word_timeout(); - move_to_getting_preamble(); - } -} - -bool heron_packet_manager::sync_word_timeout() const{ - return counter >= 50; -} - -void heron_packet_manager::process_size_byte_bit(uint8_t bit){ - append_bit_to_size_byte(bit); - debug_log_getting_size_byte(); - if(size_byte_identified()){ - if(packet.size_byte == 0) move_to_getting_checksum(); - else move_to_getting_data(); - debug_log_finished_size_byte(); - } -} - -void heron_packet_manager::process_data_bit(uint8_t bit){ - append_bit_to_data(bit); - debug_log_getting_data(); - if(data_identified()){ - move_to_getting_checksum(); - debug_log_finished_data(); - } -} - -void heron_packet_manager::process_checksum_bit(uint8_t bit){ - - append_bit_to_checksum(bit); - debug_log_getting_checksum(); - if(checksum_identified()){ - debug_log_finished_checksum(); - if(checksum_matches()) - process_finished_data(); - else - handle_invalid_checksum(); - } -} - -void heron_packet_manager::process_finished_data(){ - debug_log_summarize_data(); - // append carriage return for ESTTC protocol - packet.data.push_back(0x0D); - notify_data_available(); -} - -void heron_packet_manager::handle_invalid_checksum(){ - DEBUG_STREAM("PACKET RECEIVED - INVALID CHECKSUM\n"); - move_to_getting_preamble(); -} - -void heron_packet_manager::debug_log_getting_preamble() const{ - DEBUG_STREAM("getting preamble: 0x" << packet.preamble << '\n'); -} -void heron_packet_manager::debug_log_getting_sync_word() const{ - DEBUG_STREAM("getting sync word: 0x" << (int)(packet.sync_word) << '\n'); -} -void heron_packet_manager::debug_log_getting_size_byte() const{ - DEBUG_STREAM("getting size byte: 0x" << (int)(packet.size_byte) << '\n'); -} -void heron_packet_manager::debug_log_getting_data() const{ - DEBUG_STREAM("getting data\n"); -} -void heron_packet_manager::debug_log_getting_checksum() const{ - DEBUG_STREAM("getting checksum: 0x" << packet.checksum << '\n'); -} - -void heron_packet_manager::debug_log_finished_preamble() const{ - DEBUG_STREAM(" ::: Finished getting preamble ::: " << std::endl); -} -void heron_packet_manager::debug_log_finished_sync_word() const{ - DEBUG_STREAM(" ::: Finished getting sync word ::: " << std::endl); -} -void heron_packet_manager::debug_log_sync_word_timeout() const{ - DEBUG_STREAM(" !!! Sync word timeout !!! " << std::endl); -} -void heron_packet_manager::debug_log_finished_size_byte() const{ - DEBUG_STREAM(std::dec); - DEBUG_STREAM(" ::: Finished getting size byte: " << (int)(packet.size_byte) << " bytes expected ::: " << std::endl); - DEBUG_STREAM(std::hex); -} -void heron_packet_manager::debug_log_finished_data() const{ - DEBUG_STREAM(" ::: Finished getting data ::: " << std::endl); -} -void heron_packet_manager::debug_log_finished_checksum() const{ - DEBUG_STREAM(" ::: Finished getting checksum ::: " << std::endl); -} - -void heron_packet_manager::debug_log_summarize_data() const{ - #ifdef DEBUG_LOGGER - debug_logger << "PACKET RECEIVED - VALID CHECKSUM\n"; - debug_logger << "Packet length: " << std::to_string(packet.size_byte) << std::endl; - debug_logger << "Packet contents (HEX): " << std::endl; - for (uint8_t j = 0; j < packet.size_byte; j++) { - debug_logger << "0x" << std::setfill('0') << std::setw(2) << (int)(packet.data[j]) << " "; - } - debug_logger << std::endl; - debug_logger << "Packet contents (regular text): " << std::endl; - for (uint8_t j = 0; j < packet.size_byte; j++) { - debug_logger << packet.data[j] << " "; - } - debug_logger << std::endl; - debug_logger << "================================" << std::endl; - #endif -} diff --git a/lib/utils/heron_packet_manager.h b/lib/utils/heron_packet_manager.h deleted file mode 100644 index dcf2cec..0000000 --- a/lib/utils/heron_packet_manager.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef INCLUDED_HERON_PACKET_MANAGER_H -#define INCLUDED_HERON_PACKET_MANAGER_H - -#include "heron_packet.h" - -enum rx_recog_state { - getting_preamble, - getting_sync_word, - getting_size_byte, - getting_data, - getting_checksum, - finished_packet, -}; - -class heron_packet_manager { -private: - - heron_packet packet; - int counter; - rx_recog_state state; - - template - void append_bit(uint8_t bit, T& data); - void append_bit_to_preamble(uint8_t bit); - void append_bit_to_sync_word(uint8_t bit); - void append_bit_to_size_byte(uint8_t bit); - void append_bit_to_data(uint8_t bit); - void append_bit_to_checksum(uint8_t bit); - - bool preamble_identified() const; - bool sync_word_identified() const; - bool size_byte_identified() const; - bool data_identified() const; - bool checksum_identified() const; - - void move_to_getting_preamble(); - void move_to_getting_sync_word(); - void move_to_getting_size_byte(); - void move_to_getting_data(); - void move_to_getting_checksum(); - void notify_data_available(); - - void process_preamble_bit(uint8_t bit); - void process_sync_word_bit(uint8_t bit); - void process_size_byte_bit(uint8_t bit); - void process_data_bit(uint8_t bit); - void process_checksum_bit(uint8_t bit); - void process_finished_data(); - - void debug_log_getting_preamble() const; - void debug_log_getting_sync_word() const; - void debug_log_getting_size_byte() const; - void debug_log_getting_data() const; - void debug_log_getting_checksum() const; - - void debug_log_finished_preamble() const; - void debug_log_finished_sync_word() const; - void debug_log_sync_word_timeout() const; - void debug_log_finished_size_byte() const; - void debug_log_finished_data() const; - void debug_log_finished_checksum() const; - - void debug_log_summarize_data() const; - - void clear(); - bool sync_word_timeout() const; - uint16_t crc16() const; - bool checksum_matches() const; - void handle_invalid_checksum(); - -public: - - heron_packet_manager(); - - void process_bit(uint8_t bit); - uint8_t pop_data(); - bool data_available(); -}; - -#endif \ No newline at end of file diff --git a/python/UTAT_HERON/CMakeLists.txt b/python/UTAT_HERON/CMakeLists.txt index edd67b3..43e375f 100644 --- a/python/UTAT_HERON/CMakeLists.txt +++ b/python/UTAT_HERON/CMakeLists.txt @@ -39,7 +39,6 @@ add_custom_target( COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/test_modules/gnuradio/UTAT_HERON/ ) -GR_ADD_TEST(qa_heron_rx_bb ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_heron_rx_bb.py) GR_ADD_TEST(qa_esttc_framer ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_esttc_framer.py) GR_ADD_TEST(qa_esttc_deframer ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_esttc_deframer.py) GR_ADD_TEST(qa_tagged_stream_fixed_length_padder ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_tagged_stream_fixed_length_padder.py) diff --git a/python/UTAT_HERON/bindings/CMakeLists.txt b/python/UTAT_HERON/bindings/CMakeLists.txt index 717f259..c9b4c77 100644 --- a/python/UTAT_HERON/bindings/CMakeLists.txt +++ b/python/UTAT_HERON/bindings/CMakeLists.txt @@ -28,7 +28,6 @@ include(GrPybind) # Python Bindings ######################################################################## list(APPEND UTAT_HERON_python_files - heron_rx_bb_python.cc header_format_esttc_python.cc esttc_framer_python.cc esttc_deframer_python.cc diff --git a/python/UTAT_HERON/bindings/docstrings/heron_rx_bb_pydoc_template.h b/python/UTAT_HERON/bindings/docstrings/heron_rx_bb_pydoc_template.h deleted file mode 100644 index cbf30f1..0000000 --- a/python/UTAT_HERON/bindings/docstrings/heron_rx_bb_pydoc_template.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2023 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, UTAT_HERON, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_UTAT_HERON_heron_rx_bb = R"doc()doc"; - - -static const char* __doc_gr_UTAT_HERON_heron_rx_bb_make = R"doc()doc"; diff --git a/python/UTAT_HERON/bindings/heron_rx_bb_python.cc b/python/UTAT_HERON/bindings/heron_rx_bb_python.cc deleted file mode 100644 index 6e7a39b..0000000 --- a/python/UTAT_HERON/bindings/heron_rx_bb_python.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2023 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(heron_rx_bb.h) */ -/* BINDTOOL_HEADER_FILE_HASH(2a0494bcb857fa076a6c5a0c4f60230d) */ -/***********************************************************************************/ - -#include -#include -#include - -namespace py = pybind11; - -#include -// pydoc.h is automatically generated in the build directory -#include - -void bind_heron_rx_bb(py::module& m) -{ - - using heron_rx_bb = gr::UTAT_HERON::heron_rx_bb; - - - py::class_>( - m, "heron_rx_bb", D(heron_rx_bb)) - - .def(py::init(&heron_rx_bb::make), D(heron_rx_bb, make)) - - - ; -} diff --git a/python/UTAT_HERON/bindings/python_bindings.cc b/python/UTAT_HERON/bindings/python_bindings.cc index 3f78a66..e3e11a0 100644 --- a/python/UTAT_HERON/bindings/python_bindings.cc +++ b/python/UTAT_HERON/bindings/python_bindings.cc @@ -21,7 +21,6 @@ namespace py = pybind11; // Please do not delete /**************************************/ // BINDING_FUNCTION_PROTOTYPES( - void bind_heron_rx_bb(py::module& m); void bind_header_format_esttc(py::module& m); void bind_esttc_framer(py::module& m); void bind_esttc_deframer(py::module& m); @@ -56,7 +55,6 @@ PYBIND11_MODULE(UTAT_HERON_python, m) // Please do not delete /**************************************/ // BINDING_FUNCTION_CALLS( - bind_heron_rx_bb(m); bind_header_format_esttc(m); bind_esttc_framer(m); bind_esttc_deframer(m); diff --git a/python/UTAT_HERON/qa_heron_rx_bb.py b/python/UTAT_HERON/qa_heron_rx_bb.py deleted file mode 100755 index 1220fd5..0000000 --- a/python/UTAT_HERON/qa_heron_rx_bb.py +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Copyright 2023 University of Toronto Aerospace Team. -# -# SPDX-License-Identifier: GPL-3.0-or-later -# - -from gnuradio import gr, gr_unittest -from gnuradio import blocks -try: - from gnuradio.UTAT_HERON import heron_rx_bb -except ImportError: - import os - import sys - dirname, filename = os.path.split(os.path.abspath(__file__)) - sys.path.append(os.path.join(dirname, "bindings")) - from gnuradio.UTAT_HERON import heron_rx_bb - -# ==================================================== -# run tests individually to get proper debug file output. -# disable test by adding underscore in front of name of -# the function that starts with the word "test". -# ==================================================== - -class qa_heron_rx_bb(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_instance(self): - instance = heron_rx_bb() - - def test_001_single_byte(self): - samp_rate = 1e6 - input = [ - 0xAA,0xAA,0xAA,0xAA,0xAA,0x7E,1,0x69,0xD3,0xB1 - ] - expected = [ - 0x69, 0x0D - ] - throttle = blocks.throttle(gr.sizeof_char*1, samp_rate, True) - src = blocks.vector_source_b(input, False, 1, []) - unpack = blocks.unpack_k_bits_bb(8) - rx = heron_rx_bb() - rx.set_max_noutput_items(len(expected)) - dst = blocks.vector_sink_b() - self.tb.connect(src, unpack) - self.tb.connect(unpack, rx) - self.tb.connect(rx, dst) - self.tb.run() - output = dst.data() - self.assertEqual(expected, output) - - def test_002_multiple_bytes(self): - samp_rate = 1e6 - input = [ - 0xAB,0xAB,0xBA,0xFA,0x24, - 0xAB,0xAB,0xBA,0xFA,0x24, - 0xAB,0xAB,0xBA,0xFA,0x24, - 0xAA,0xAA,0xAA,0xAA,0xAA,0x7E,1,0x01,0x3E,0x1F, - 0xAB,0xAB,0xBA,0xFA,0x24, - 0xAA,0xAA,0xAA,0xAA,0xAA,0x7E,3,0x61,0x62,0x63,0x82,0xCA, - 0xAB,0xAB,0xBA,0xFA,0x24, - 0xAA,0xAA,0xAA,0xAA,0xAA,0x7E,6,0x69,0x69,0x69,0x69,0x69,0x69,0x15,0xD3, - 0xAA,0xAA,0xAA,0xAA,0xAA,0x7E,6,0x69,0x69,0x69,0x69,0x69,0x69,0x15,0xD3, - ] - expected = [ - 0x01,0x0D, - 0x61,0x62,0x63,0x0D, - 0x69,0x69,0x69,0x69,0x69,0x69,0x0D, - 0x69,0x69,0x69,0x69,0x69,0x69,0x0D - ] - throttle = blocks.throttle(gr.sizeof_char*1, samp_rate, True) - src = blocks.vector_source_b(input, False, 1, []) - unpack = blocks.unpack_k_bits_bb(8) - rx = heron_rx_bb() - rx.set_max_noutput_items(len(expected)) - dst = blocks.vector_sink_b() - self.tb.connect(src, unpack) - self.tb.connect(unpack, rx) - self.tb.connect(rx, dst) - self.tb.run() - output = dst.data() - self.assertEqual(expected, output) - - def test_003_timeout(self): - samp_rate = 1e6 - input = [ - 0xAA,0xAA,0xAA,0xAA,0xAA,0x7E,6,0x69,0x69,0x69,0x69,0x69,0x69,0x15,0xD3, - 0xAA,0xAA,0xAA,0xAA,0xAA, - 0xAA,0xAA,0xAA,0xAA,0xAA,0x7E,6,0x69,0x69,0x69,0x69,0x69,0x69,0x15,0xD3, # should timeout - 0xAA,0xAA,0xAA,0xAA,0xAA, - 0xAB,0xAB,0xBA,0xFA,0x24, # should timeout - ] - expected = [ - 0x69,0x69,0x69,0x69,0x69,0x69,0x0D - ] - throttle = blocks.throttle(gr.sizeof_char*1, samp_rate, True) - src = blocks.vector_source_b(input, False, 1, []) - unpack = blocks.unpack_k_bits_bb(8) - rx = heron_rx_bb() - rx.set_max_noutput_items(len(expected)) - dst = blocks.vector_sink_b() - self.tb.connect(src, unpack) - self.tb.connect(unpack, rx) - self.tb.connect(rx, dst) - self.tb.run() - output = dst.data() - self.assertEqual(expected, output) - - def test_004_zero_data(self): - samp_rate = 1e6 - input = [ - 0xAB,0xAB,0xBA,0xFA,0x24, - 0xAA,0xAA,0xAA,0xAA,0xAA,0x7E,1,0x01,0x3E,0x1F, - 0xAB,0xAB,0xBA,0xFA,0x24, - 0xAB,0xAB,0xBA,0xFA,0x24, - 0xAA,0xAA,0xAA,0xAA,0xAA,0x7E,0,0xE1,0xF0 - - ] - expected = [ - 0x01,0x0D, - 0x0D - ] - throttle = blocks.throttle(gr.sizeof_char*1, samp_rate, True) - src = blocks.vector_source_b(input, False, 1, []) - unpack = blocks.unpack_k_bits_bb(8) - rx = heron_rx_bb() - rx.set_max_noutput_items(len(expected)) - dst = blocks.vector_sink_b() - self.tb.connect(src, unpack) - self.tb.connect(unpack, rx) - self.tb.connect(rx, dst) - self.tb.run() - output = dst.data() - self.assertEqual(expected, output) - -if __name__ == '__main__': - gr_unittest.run(qa_heron_rx_bb)