Skip to content

Commit

Permalink
Created header_format_esttc in hopes of replacing heron_rx_bb. Listed…
Browse files Browse the repository at this point in the history
… heron_rx_bb as deprecated.
  • Loading branch information
swarnavaghosh04 committed Aug 5, 2023
1 parent d36c9cc commit dddc7cc
Show file tree
Hide file tree
Showing 13 changed files with 325 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ endif()
# Make sure our local CMake Modules path comes first
list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake/Modules)
# Find gnuradio to get access to the cmake modules
find_package(Gnuradio "3.10" REQUIRED)
find_package(Gnuradio "3.10" REQUIRED COMPONENTS blocks digital filter analog fft)

# Set the version information here
# cmake-format: off
Expand Down
3 changes: 2 additions & 1 deletion grc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
#

install(FILES
UTAT_HERON_heron_rx_bb.block.yml DESTINATION share/gnuradio/grc/blocks
UTAT_HERON_heron_rx_bb.block.yml
UTAT_HERON_header_format_esttc.block.yml DESTINATION share/gnuradio/grc/blocks
)
56 changes: 56 additions & 0 deletions grc/UTAT_HERON_header_format_esttc.block.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
id: UTAT_HERON_header_format_esttc
label: ESTTC Header Format
category: '[UTAT]'
flags: [ show_id, python, cpp ]

value: ${ UTAT_HERON.header_format_esttc() }

templates:
imports: from gnuradio import UTAT_HERON
var_make: self.${id} = ${id} = UTAT_HERON.header_format_esttc()

cpp_templates:
includes: ['#include <gnuradio/UTAT_HERON/header_format_esttc.h>']
declarations: 'UTAT_HERON::header_format_esttc::sptr ${id};'
var_make: this->${id} = ${id} = UTAT_HERON::header_format_esttc();
link: ['gnuradio::gnuradio-digital']

# Make one 'parameters' list entry for every parameter you want settable from the GUI.
# Keys include:
# * id (makes the value accessible as keyname, e.g. in the make entry)
# * label (label shown in the GUI)
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...)
# * default
# parameters:
# - id: parametername_replace_me
# label: FIX ME:
# dtype: string
# default: You need to fill in your grc/UTAT_HERON_header_format_esttc.block.yaml
#- id: ...
# label: ...
# dtype: ...

# Make one 'inputs' list entry per input and one 'outputs' list entry per output.
# Keys include:
# * label (an identifier for the GUI)
# * domain (optional - stream or message. Default is stream)
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...)
# * vlen (optional - data stream vector length. Default is 1)
# * optional (optional - set to 1 for optional inputs. Default is 0)
inputs:
#- label: ...
# domain: ...
# dtype: ...
# vlen: ...
# optional: ...

outputs:
#- label: ...
# domain: ...
# dtype: ...
# vlen: ...
# optional: ...

# 'file_format' specifies the version of the GRC yml format used in the file
# and should usually not be changed.
file_format: 1
1 change: 1 addition & 0 deletions grc/UTAT_HERON_heron_rx_bb.block.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
id: UTAT_HERON_heron_rx_bb
label: HERON RX BB
category: '[UTAT]'
flags: '[ deprecated ]'

templates:
imports: from gnuradio import UTAT_HERON
Expand Down
3 changes: 2 additions & 1 deletion include/gnuradio/UTAT_HERON/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
########################################################################
install(FILES
api.h
heron_rx_bb.h DESTINATION include/gnuradio/UTAT_HERON
heron_rx_bb.h
header_format_esttc.h DESTINATION include/gnuradio/UTAT_HERON
)
45 changes: 45 additions & 0 deletions include/gnuradio/UTAT_HERON/header_format_esttc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* -*- c++ -*- */
/*
* Copyright 2023 University of Toronto Aerospace Team.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#ifndef INCLUDED_UTAT_HERON_HEADER_FORMAT_ESTTC_H
#define INCLUDED_UTAT_HERON_HEADER_FORMAT_ESTTC_H

#include <gnuradio/UTAT_HERON/api.h>
#include <gnuradio/digital/header_format_default.h>

namespace gr {
namespace UTAT_HERON {

/*!
* \brief <+description+>
*
*/
class UTAT_HERON_API header_format_esttc : public gr::digital::header_format_default
{
public:
typedef std::shared_ptr<header_format_esttc> sptr;
static sptr make();
header_format_esttc();
~header_format_esttc();
bool format(
int nbytes_in,
const unsigned char* input,
pmt::pmt_t& output,
pmt::pmt_t& info) override;
size_t header_nbits() const override;
protected:
void enter_have_sync() override;
void enter_have_header(int payload_len) override;
void enter_search() override;
bool header_ok() override;
int header_payload() override;
};

} // namespace UTAT_HERON
} // namespace gr

#endif /* INCLUDED_UTAT_HERON_HEADER_FORMAT_ESTTC_H */
4 changes: 3 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ list(APPEND UTAT_HERON_sources
heron_packet.h
debug_logger.cc
debug_logger.h
header_format_esttc.cc
)

set(DEBUG_FILE "${CMAKE_BINARY_DIR}/debug_log.txt" CACHE FILEPATH
Expand All @@ -31,7 +32,7 @@ if(NOT UTAT_HERON_sources)
endif(NOT UTAT_HERON_sources)

add_library(gnuradio-UTAT_HERON SHARED ${UTAT_HERON_sources})
target_link_libraries(gnuradio-UTAT_HERON gnuradio::gnuradio-runtime)
target_link_libraries(gnuradio-UTAT_HERON gnuradio::gnuradio-runtime gnuradio::gnuradio-digital)
target_include_directories(gnuradio-UTAT_HERON
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
PUBLIC $<INSTALL_INTERFACE:include>
Expand Down Expand Up @@ -67,6 +68,7 @@ include(GrTest)
#include_directories()
# List all files that contain Boost.UTF unit tests here
list(APPEND test_UTAT_HERON_sources
qa_header_format_esttc.cc
)
# Anything we need to link to for the unit tests go here
list(APPEND GR_TEST_TARGET_DEPS gnuradio-UTAT_HERON)
Expand Down
80 changes: 80 additions & 0 deletions lib/header_format_esttc.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* -*- c++ -*- */
/*
* Copyright 2023 University of Toronto Aerospace Team.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#include <gnuradio/UTAT_HERON/header_format_esttc.h>
#include <gnuradio/io_signature.h>
#include <volk/volk_alloc.hh>

namespace gr {
namespace UTAT_HERON {

header_format_esttc::sptr header_format_esttc::make(){
return header_format_esttc::sptr(new header_format_esttc());
}

header_format_esttc::header_format_esttc():
header_format_default("101010101010101010101010101010101010101001111110", 3, 1)
{}

header_format_esttc::~header_format_esttc() {}

bool header_format_esttc::format(int nbytes_in,
const unsigned char* input,
pmt::pmt_t& output,
pmt::pmt_t& info)
{

if(nbytes_in > 128)
throw std::runtime_error("header_format_esttc: Packet length cannot exceed 128 bits");

// Creating the output pmt copies data; free our own here when done.
volk::vector<uint8_t> bytes_out(header_nbytes());

gr::digital::header_buffer header(bytes_out.data());
header.add_field64(d_access_code, d_access_code_len);
header.add_field8((uint8_t)(nbytes_in));

// Package output data into a PMT vector
output = pmt::init_u8vector(header_nbytes(), bytes_out.data());

return true;
}


size_t header_format_esttc::header_nbits() const{
return d_access_code_len + 8 * 1 * sizeof(uint8_t);
}

inline void header_format_esttc::enter_have_sync(){
d_state = STATE_HAVE_SYNC;
d_hdr_reg.clear();
}
inline void header_format_esttc::enter_have_header(int payload_len){
d_state = STATE_SYNC_SEARCH;
d_pkt_len = payload_len;
d_pkt_count = 0;
}
inline void header_format_esttc::enter_search(){
d_state = STATE_SYNC_SEARCH;
}

bool header_format_esttc::header_ok(){
return d_hdr_reg.length() == 8 * 1 * sizeof(uint8_t);
}

int header_format_esttc::header_payload(){

uint8_t len = d_hdr_reg.extract_field16(0, 8);

d_info = pmt::make_dict();
d_info = pmt::dict_add(
d_info, pmt::intern("payload symbols"), pmt::from_long(8 * len / d_bps));
return static_cast<int>(len);
}

} /* namespace UTAT_HERON */
} /* namespace gr */
22 changes: 22 additions & 0 deletions lib/qa_header_format_esttc.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* -*- c++ -*- */
/*
* Copyright 2023 University of Toronto Aerospace Team.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#include <gnuradio/UTAT_HERON/header_format_esttc.h>
#include <gnuradio/attributes.h>
#include <boost/test/unit_test.hpp>

namespace gr {
namespace UTAT_HERON {

BOOST_AUTO_TEST_CASE(test_header_format_esttc_replace_with_specific_test_name)
{
// Put test here
BOOST_TEST(1);
}

} /* namespace UTAT_HERON */
} /* namespace gr */
3 changes: 2 additions & 1 deletion python/UTAT_HERON/bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ include(GrPybind)
########################################################################

list(APPEND UTAT_HERON_python_files
heron_rx_bb_python.cc python_bindings.cc)
heron_rx_bb_python.cc
header_format_esttc_python.cc python_bindings.cc)

GR_PYBIND_MAKE_OOT(UTAT_HERON
../../..
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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_header_format_esttc = R"doc()doc";


static const char *__doc_gr_UTAT_HERON_header_format_esttc_header_format_esttc = R"doc()doc";


static const char *__doc_gr_UTAT_HERON_header_format_esttc_make = R"doc()doc";


static const char *__doc_gr_UTAT_HERON_header_format_esttc_format = R"doc()doc";


static const char *__doc_gr_UTAT_HERON_header_format_esttc_header_nbits = R"doc()doc";


75 changes: 75 additions & 0 deletions python/UTAT_HERON/bindings/header_format_esttc_python.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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(header_format_esttc.h) */
/* BINDTOOL_HEADER_FILE_HASH(41bda5cf854f7a82ab2d53b92e58e7f5) */
/***********************************************************************************/

#include <pybind11/complex.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

namespace py = pybind11;

#include <gnuradio/UTAT_HERON/header_format_esttc.h>
// pydoc.h is automatically generated in the build directory
#include <header_format_esttc_pydoc.h>

void bind_header_format_esttc(py::module& m)
{

using header_format_esttc = gr::UTAT_HERON::header_format_esttc;


py::class_<header_format_esttc, gr::digital::header_format_default,
std::shared_ptr<header_format_esttc>>(m, "header_format_esttc", D(header_format_esttc))

.def(py::init(&header_format_esttc::make),
D(header_format_esttc,make)
)
.def_static(
"make",
&header_format_esttc::make,
D(header_format_esttc,make)
)
.def(
"format",
&header_format_esttc::format,
py::arg("nbytes_in"),
py::arg("input"),
py::arg("output"),
py::arg("info"),
D(header_format_esttc, format))
.def(
"header_nbits",
&header_format_esttc::header_nbits,
D(header_format_esttc, header_nbits))



;




}








Loading

0 comments on commit dddc7cc

Please sign in to comment.