Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added cpp code generation capability to Rx blocks #78

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,51 @@
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)


# Branch Info
We implement c++ code generation capability to all sub-blocks in this repo.
This means adding the following lines to each of the blocks' .yml files:

* ```
flags: [python, cpp]
```
* ```
cpp_templates:
includes: ['#include <gnuradio/lora_sdr/<BLOCK_NAME>.h>']
declarations: 'lora_sdr::<BLOCK_NAME>::sptr ${id};'
make: 'this->${id} = lora_sdr::<BLOCK_NAME>::make(<PARAMS>);'
packages: ['gnuradio-lora_sdr']
link: ['gnuradio::gnuradio-lora_sdr']
translations:
'False': 'false'
'True': 'true'
\[: '{'
\]: '}'
```

notice the <BLOCK_NAME> and <PARAMS> tag.
for example you can look at `/grc/lora_sdr_frame_sync.block.yml` where it is already implemented

Rx Blocks:
- [x] lora_sdr_fft_demod.block.yml
- [x] lora_sdr_gray_mapping.block.yml
- [x] lora_sdr_deinterleaver.block.yml
- [x] lora_sdr_hamming_dec.block.yml
- [x] lora_sdr_header_decoder.block.yml
- [x] lora_sdr_dewhitening.block.yml
- [x] lora_sdr_crc_verif.block.yml

Tx Blocks:
- [x] lora_sdr_data_source.block.yml
- [x] lora_sdr_gray_demap.block.yml
- [x] lora_sdr_hamming_enc.block.yml
- [x] lora_sdr_header.block.yml
- [x] lora_sdr_whitening.block.yml
- [x] lora_sdr_payload_id_inc.block.yml
- [x] lora_sdr_RH_RF95_header.block.yml
- [x] lora_sdr_modulate.block.yml
- [x] lora_sdr_interleaver.block.yml
- [x] lora_sdr_add_crc.block.yml

## Summary
This is the fully-functional GNU Radio software-defined radio (SDR) implementation of a LoRa transceiver with all the necessary receiver components to operate correctly even at very low SNRs. The transceiver is available as a module for GNU Radio 3.10. This work has been conducted at the Telecommunication Circuits Laboratory, EPFL.

Expand Down
234 changes: 234 additions & 0 deletions examples/rx_cpp.grc
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
options:
parameters:
author: ''
catch_exceptions: 'True'
category: '[GRC Hier Blocks]'
cmake_opt: ''
comment: ''
copyright: ''
description: ''
gen_cmake: 'On'
gen_linking: dynamic
generate_options: no_gui
hier_block_src_path: '.:'
id: rx_cpp
max_nouts: '0'
output_language: cpp
placement: (0,0)
qt_qss_theme: ''
realtime_scheduling: ''
run: 'True'
run_command: '{python} -u {filename}'
run_options: prompt
sizing_mode: fixed
thread_safe_setters: ''
title: rx_cpp
window_size: (1000,1000)
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [8, 8]
rotation: 0
state: enabled

blocks:
- name: samp_rate
id: variable
parameters:
comment: ''
value: 4e6
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [184, 12]
rotation: 0
state: enabled
- name: soft_decoding
id: variable
parameters:
comment: ''
value: 'True'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [296, 12.0]
rotation: 0
state: enabled
- name: blocks_null_source_0
id: blocks_null_source
parameters:
affinity: ''
alias: ''
bus_structure_source: '[[0,],]'
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
num_outputs: '1'
type: complex
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [112, 280.0]
rotation: 0
state: enabled
- name: lora_sdr_crc_verif_0
id: lora_sdr_crc_verif
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
output_crc_check: 'False'
print_rx_msg: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [712, 384.0]
rotation: 0
state: enabled
- name: lora_sdr_deinterleaver_1
id: lora_sdr_deinterleaver
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
soft_decoding: soft_decoding
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [880, 292.0]
rotation: 0
state: enabled
- name: lora_sdr_dewhitening_0
id: lora_sdr_dewhitening
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [544, 400.0]
rotation: 0
state: enabled
- name: lora_sdr_fft_demod_0
id: lora_sdr_fft_demod
parameters:
affinity: ''
alias: ''
comment: ''
max_log_approx: 'True'
maxoutbuf: '0'
minoutbuf: '0'
soft_decoding: soft_decoding
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [496, 292.0]
rotation: 0
state: enabled
- name: lora_sdr_frame_sync_0
id: lora_sdr_frame_sync
parameters:
affinity: ''
alias: ''
bandwidth: int(500e3)
center_freq: int(95e6)
comment: ''
impl_head: 'False'
maxoutbuf: '0'
minoutbuf: '0'
os_factor: '4'
preamb_len: '8'
sf: '5'
show_log_port: 'False'
sync_word: '18'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [328, 260.0]
rotation: 0
state: enabled
- name: lora_sdr_gray_mapping_0
id: lora_sdr_gray_mapping
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
soft_decoding: soft_decoding
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [688, 292.0]
rotation: 0
state: enabled
- name: lora_sdr_hamming_dec_0
id: lora_sdr_hamming_dec
parameters:
affinity: ''
alias: ''
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
soft_decoding: soft_decoding
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [104, 396.0]
rotation: 0
state: enabled
- name: lora_sdr_header_decoder_0
id: lora_sdr_header_decoder
parameters:
affinity: ''
alias: ''
comment: ''
cr: '3'
has_crc: 'False'
impl_head: 'False'
ldro: '2'
maxoutbuf: '0'
minoutbuf: '0'
pay_len: '255'
print_header: 'True'
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [312, 396.0]
rotation: 0
state: enabled

connections:
- [blocks_null_source_0, '0', lora_sdr_frame_sync_0, '0']
- [lora_sdr_deinterleaver_1, '0', lora_sdr_hamming_dec_0, '0']
- [lora_sdr_dewhitening_0, '0', lora_sdr_crc_verif_0, '0']
- [lora_sdr_fft_demod_0, '0', lora_sdr_gray_mapping_0, '0']
- [lora_sdr_frame_sync_0, '0', lora_sdr_fft_demod_0, '0']
- [lora_sdr_gray_mapping_0, '0', lora_sdr_deinterleaver_1, '0']
- [lora_sdr_hamming_dec_0, '0', lora_sdr_header_decoder_0, '0']
- [lora_sdr_header_decoder_0, '0', lora_sdr_dewhitening_0, '0']
- [lora_sdr_header_decoder_0, frame_info, lora_sdr_frame_sync_0, frame_info]

metadata:
file_format: 1
grc_version: v3.11.0.0git-645-g506e68df
13 changes: 13 additions & 0 deletions grc/lora_sdr_RH_RF95_header.block.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
id: lora_sdr_RH_RF95_header
label: Rh rf95 header
category: '[LoRa_TX]'
flags: [python,cpp]

parameters:
- id: _to
Expand All @@ -16,6 +17,18 @@ parameters:
label: _flags
dtype: int

cpp_templates:
includes: ['#include <gnuradio/lora_sdr/RH_RF95_header.h>']
declarations: 'lora_sdr::RH_RF95_header::sptr ${id};'
make: 'this->${id} = lora_sdr::RH_RF95_header::make(${_to}, ${_from}, ${_id}, ${_flags});'
packages: ['gnuradio-lora_sdr']
link: ['gnuradio::gnuradio-lora_sdr']
translations:
'False': 'false'
'True': 'true'
\[: '{'
\]: '}'

inputs:
- domain: message
id: msg
Expand Down
13 changes: 13 additions & 0 deletions grc/lora_sdr_add_crc.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@
id: lora_sdr_add_crc
label: Add crc
category: '[LoRa_TX]'
flags: [python,cpp]

parameters:
- id: has_crc
label: Has_crc
dtype: bool
default: 'False'

cpp_templates:
includes: ['#include <gnuradio/lora_sdr/add_crc.h>']
declarations: 'lora_sdr::add_crc::sptr ${id};'
make: 'this->${id} = lora_sdr::add_crc::make(${has_crc});'
packages: ['gnuradio-lora_sdr']
link: ['gnuradio::gnuradio-lora_sdr']
translations:
'False': 'false'
'True': 'true'
\[: '{'
\]: '}'

inputs:
- domain: stream
dtype: byte
Expand Down
13 changes: 13 additions & 0 deletions grc/lora_sdr_crc_verif.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
id: lora_sdr_crc_verif
label: CRC verif
category: '[LoRa_RX]'
flags: [python,cpp]

parameters:
- id: print_rx_msg
Expand All @@ -18,6 +19,18 @@ parameters:
option_labels: ['No', 'Yes']
default: 'False'

cpp_templates:
includes: ['#include <gnuradio/lora_sdr/crc_verif.h>']
declarations: 'lora_sdr::crc_verif::sptr ${id};'
make: 'this->${id} = lora_sdr::crc_verif::make(${print_rx_msg}, ${output_crc_check});'
packages: ['gnuradio-lora_sdr']
link: ['gnuradio::gnuradio-lora_sdr']
translations:
'False': 'false'
'True': 'true'
\[: '{'
\]: '}'

inputs:
- domain: stream
dtype: byte
Expand Down
13 changes: 13 additions & 0 deletions grc/lora_sdr_data_source.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
id: lora_sdr_data_source
label: Data source
category: '[LoRa_TX]'
flags: [python,cpp]

parameters:
- id: pay_len
Expand All @@ -12,6 +13,18 @@ parameters:
label: N_frames
dtype: int

cpp_templates:
includes: ['#include <gnuradio/lora_sdr/data_source.h>']
declarations: 'lora_sdr::data_source::sptr ${id};'
make: 'this->${id} = lora_sdr::data_source::make(${pay_len}, ${n_frames});'
packages: ['gnuradio-lora_sdr']
link: ['gnuradio::gnuradio-lora_sdr']
translations:
'False': 'false'
'True': 'true'
\[: '{'
\]: '}'

inputs:
- domain: message
id: trigg
Expand Down
Loading