Skip to content

Commit

Permalink
config format to specify decoding chain
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Schmidl <[email protected]>
  • Loading branch information
tanneberger and marenz2569 committed May 15, 2024
1 parent 8719a14 commit d503ccc
Show file tree
Hide file tree
Showing 17 changed files with 1,089 additions and 213 deletions.
8 changes: 8 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
BasedOnStyle: LLVM
Language: Cpp
IndentWidth: 2
BreakConstructorInitializersBeforeComma: 'true'
AllowShortFunctionsOnASingleLine: All
PointerAlignment: Left
ColumnLimit: 120
214 changes: 214 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
Checks: '
clang-diagnostic-*,
boost-*,
Google-*,
clang-analyzer-*,
modernize-*,
performance-*,
portability-*,
readability-*,
cppcoreguidelines-*,
llvm-*,
cert-*,
-clang-analyzer-core.CallAndMessage'
WarningsAsErrors: true
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues
value: '1.0;100.0;'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues
value: '1;2;3;4;'
- key: cppcoreguidelines-explicit-virtual-functions.FinalSpelling
value: final
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-explicit-virtual-functions.OverrideSpelling
value: override
- key: cppcoreguidelines-macro-usage.AllowedRegexp
value: '^DEBUG_*'
- key: cppcoreguidelines-macro-usage.CheckCapsOnly
value: '0'
- key: cppcoreguidelines-macro-usage.IgnoreCommandLineMacros
value: '1'
- key: cppcoreguidelines-no-malloc.Allocations
value: '::malloc;::calloc'
- key: cppcoreguidelines-no-malloc.Deallocations
value: '::free'
- key: cppcoreguidelines-no-malloc.Reallocations
value: '::realloc'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: cppcoreguidelines-owning-memory.LegacyResourceConsumers
value: '::free;::realloc;::freopen;::fclose'
- key: cppcoreguidelines-owning-memory.LegacyResourceProducers
value: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile'
- key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader
value: ''
- key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle
value: 'llvm'
- key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
value: '0'
- key: cppcoreguidelines-pro-type-member-init.UseAssignment
value: '0'
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
value: '0'
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: '0'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: llvm-namespace-comment.ShortNamespaceLines
value: '1'
- key: llvm-namespace-comment.SpacesBeforeComments
value: '1'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-make-shared.IgnoreMacros
value: '1'
- key: modernize-make-shared.IncludeStyle
value: 'llvm'
- key: modernize-make-shared.MakeSmartPtrFunction
value: 'std::make_shared'
- key: modernize-make-shared.MakeSmartPtrFunctionHeader
value: memory
- key: modernize-make-unique.IgnoreMacros
value: '1'
- key: modernize-make-unique.IncludeStyle
value: 'llvm'
- key: modernize-make-unique.MakeSmartPtrFunction
value: 'std::make_unique'
- key: modernize-make-unique.MakeSmartPtrFunctionHeader
value: memory
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-pass-by-value.ValuesOnly
value: '0'
- key: modernize-raw-string-literal.ReplaceShorterLiterals
value: '0'
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-replace-random-shuffle.IncludeStyle
value: llvm
- key: modernize-use-auto.MinTypeNameLength
value: '5'
- key: modernize-use-auto.RemoveStars
value: '0'
- key: modernize-use-default-member-init.IgnoreMacros
value: '1'
- key: modernize-use-default-member-init.UseAssignment
value: '0'
- key: modernize-use-emplace.ContainersWithPushBack
value: '::std::vector;::std::list;::std::deque'
- key: modernize-use-emplace.SmartPointers
value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
- key: modernize-use-emplace.TupleMakeFunctions
value: '::std::make_pair;::std::make_tuple'
- key: modernize-use-emplace.TupleTypes
value: '::std::pair;::std::tuple'
- key: modernize-use-equals-default.IgnoreMacros
value: '1'
- key: modernize-use-equals-delete.IgnoreMacros
value: '1'
- key: modernize-use-nodiscard.ReplacementString
value: '[[nodiscard]]'
- key: modernize-use-noexcept.ReplacementString
value: ''
- key: modernize-use-noexcept.UseNoexceptFalse
value: '1'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: modernize-use-override.FinalSpelling
value: final
- key: modernize-use-override.IgnoreDestructors
value: '0'
- key: modernize-use-override.OverrideSpelling
value: override
- key: modernize-use-transparent-functors.SafeMode
value: '0'
- key: modernize-use-using.IgnoreMacros
value: '1'
- key: performance-faster-string-find.StringLikeClasses
value: 'std::basic_string'
- key: performance-for-range-copy.AllowedTypes
value: ''
- key: performance-for-range-copy.WarnOnAllAutoCopies
value: '0'
- key: performance-inefficient-string-concatenation.StrictMode
value: '0'
- key: performance-inefficient-vector-operation.VectorLikeClasses
value: '::std::vector'
- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: '1'
- key: performance-move-constructor-init.IncludeStyle
value: llvm
- key: performance-type-promotion-in-math-fn.IncludeStyle
value: llvm
- key: performance-unnecessary-copy-initialization.AllowedTypes
value: ''
- key: performance-unnecessary-value-param.AllowedTypes
value: ''
- key: performance-unnecessary-value-param.IncludeStyle
value: llvm
- key: portability-simd-intrinsics.Std
value: ''
- key: portability-simd-intrinsics.Suggest
value: '0'
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
- key: readability-function-size.BranchThreshold
value: '4294967295'
- key: readability-function-size.LineThreshold
value: '4294967295'
- key: readability-function-size.NestingThreshold
value: '4294967295'
- key: readability-function-size.ParameterThreshold
value: '4294967295'
- key: readability-function-size.StatementThreshold
value: '800'
- key: readability-function-size.VariableThreshold
value: '4294967295'
- key: readability-identifier-length.MinimumParameterNameLength
value: 2
- key: readability-identifier-naming.IgnoreFailedSplit
value: '0'
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: '0'
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: '0'
- key: readability-inconsistent-declaration-parameter-name.IgnoreMacros
value: '1'
- key: readability-inconsistent-declaration-parameter-name.Strict
value: '0'
- key: readability-magic-numbers.IgnoredFloatingPointValues
value: '1.0;100.0;'
- key: readability-magic-numbers.IgnoredIntegerValues
value: '1;2;3;4;'
- key: readability-redundant-smartptr-get.IgnoreMacros
value: '1'
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: '0'
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
value: '0'
- key: readability-simplify-subscript-expr.Types
value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array'
- key: readability-static-accessed-through-instance.NameSpecifierNestingThreshold
value: '3'
- key: readability-uppercase-literal-suffix.IgnoreMacros
value: '1'
- key: readability-uppercase-literal-suffix.NewSuffixes
value: ''
18 changes: 18 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: clang-format-review

# You can be more specific, but it currently only works on pull requests
on: [push, pull_request]

jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install clang-tidy
run: |
sudo apt-get update
sudo apt-get install -y clang-tidy
- name: Analyze
run: |
clang-format --dry-run --Werror -style=file $(find ./ -name '*.cpp' -print)
clang-format --dry-run --Werror -style=file $(find ./ -name '*.h' -print)
1 change: 1 addition & 0 deletions .github/workflows/tetra-receiver-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ jobs:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v17
- run: nix build -vL .\#packages.x86_64-linux.tetra-receiver
- run: ./result/bin/unit_tests
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
result
.idea
cmake-build-debug
29 changes: 24 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
cmake_minimum_required(VERSION 3.22)
project(tetra-receiver)

add_executable(tetra-receiver
src/main.cpp)
SET(CMAKE_CXX_STANDARD 17)

enable_testing()

target_compile_options(tetra-receiver PUBLIC -std=c++11 -Wall)
#
# Configure the tetra-receiver library
#
add_library(lib-tetra-receiver
src/config.cpp
)
target_include_directories(lib-tetra-receiver PUBLIC include)

include_directories(src)
#
# Build the tool
#
add_executable(tetra-receiver
src/tetra-receiver.cpp
)
target_compile_options(tetra-receiver PUBLIC -std=c++17 -Wall)

find_package(Gnuradio "3.8" REQUIRED)
find_package(Boost REQUIRED)
Expand All @@ -15,6 +29,11 @@ find_package(cxxopts REQUIRED)

include_directories(${GNURADIO_ALL_INCLUDE_DIRS})

target_link_libraries(tetra-receiver log4cpp gnuradio-digital gnuradio-analog gnuradio-filter gnuradio-blocks gnuradio-fft gnuradio-runtime gnuradio-pmt volk gnuradio-osmosdr)
target_link_libraries(tetra-receiver lib-tetra-receiver log4cpp volk gnuradio-osmosdr gnuradio-digital gnuradio-analog gnuradio-filter gnuradio-blocks gnuradio-fft gnuradio-runtime gnuradio-pmt)

install(TARGETS tetra-receiver DESTINATION bin)

#
# Testing
#
add_subdirectory(test)
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ The tetra streams can be decoding using [`tetra-rx` from the osmocom tetra proje
Usage with tetra-rx: `socat STDIO UDP-LISTEN:42000 | stdbuf -i0 -o0 tetra-rx /dev/stdin`

## Usage
The program can be either used with command line arguments or with a TOML config file, the contents are described in the section below.

```
Receive multiple TETRA streams at once and send the bits out via UDP
Usage:
tetra-receiver [OPTION...]
-h, --help Print usage
--config-file arg Instead of these options read the config from
a config file (default: "")
--rf arg RF gain (default: 10)
--if arg IF gain (default: 10)
--bb arg BB gain (default: 10)
Expand All @@ -25,3 +29,46 @@ Usage:
--udp-start arg Start UDP port. Each stream gets its own UDP
port, starting at udp-start (default: 42000)
```

## Toml Config Format

When decoding TETRA streams the downlink and uplink are often a number of MHz apart.
To solve the problem of decoding multiple uplinks and downlinks without having big FIR filters operating at the SDRs sampling rate, one wants to first decimate into two smaller streams. One for all uplink and downlink channels respectively.

Therefore this application supports multiple stages of decimation.

The config has mandatory global arguments `CenterFrequency`, `DeviceString` and `SampleRate` for the SDR.
The optional argumens `RFGain`, `IFGain` and `BBGain` are for setting the gains of the SDR, by default these are zero.

If a table specifies `Frequency`, `Host` and `Port`, the signal is directly decoded from the SDR.
If it is specified in a subtable, it is decoded from the decimated signal described by the associtated table.

If a table specifies `Frequency` and `SampleRate`, the signal from the SDR is first decimated by the given parameters and then passed to the decoders specified in the subtables.

```
CenterFrequency = unsigned int
DeviceString = "string"
SampleRate = unsigned int
RFGain = unsigned int (default 0)
IFGain = unsigned int (default 0)
BBGain = unsigned int (default 0)
[DecimateA]
Frequency = unsigned int
SampleRate = unsigned int
[DecimateA.Stream0]
Frequency = unsigned int
Host = "string"
Port = unsigned int
[DecimateA.Stream1]
Frequency = unsigned int
Host = "string"
Port = unsigned int
[Stream2]
Frequency = unsigned int
Host = "string"
Port = unsigned int
```
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-23.11;
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";

utils.url = "github:numtide/flake-utils";
};
Expand Down
Loading

0 comments on commit d503ccc

Please sign in to comment.