Fixed P25 garbled encrypted voice, plus minor several other improvements (#27)
* changed GHA runners to ubuntu-20.04 since glibc is too new in 22.04 * updated gitignore to exclude CMake and more C++ temporary files * adjusted scripts' permissions * created express Makefile to easily build for different arch * automatically clone ASIO source code using CMake * updated Raspberry Pi configuration docs * fixed P25 garbled encrypted voice due to incorrect HDU MIs, frame type predictions, and clear null IMBE frames * removed ASIO clones from pipelinespull/28/head
parent
556298890d
commit
da863f6785
@ -0,0 +1,62 @@
|
||||
# DVM Host Express Makefile
|
||||
# An express Makefile for easily creating binaries for various architectures.
|
||||
# Author: K4YT3X <i@k4yt3x.com>
|
||||
|
||||
# This Makefile helps building the dvmcmd and dvmhost binaries for all supported architectures.
|
||||
# Built binaries will be saved to build/${ARCH}. E.g., The binaries built with `make aarch64`
|
||||
# will be saved to build/aarch64.
|
||||
|
||||
all: prepare amd64 arm aarch64 armhf
|
||||
@echo 'All builds completed successfully'
|
||||
|
||||
amd64:
|
||||
@echo 'Compiling for AMD64'
|
||||
mkdir -p "build/$@" && cd "build/$@" \
|
||||
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-s" -DCMAKE_CXX_FLAGS="-s" ../.. \
|
||||
&& make -j $(nproc)
|
||||
@echo 'Successfully compiled for AMD64'
|
||||
|
||||
arm:
|
||||
@echo 'Cross-Compiling for ARM'
|
||||
mkdir -p "build/$@" && cd "build/$@" \
|
||||
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-s" -DCMAKE_CXX_FLAGS="-s" \
|
||||
-DCROSS_COMPILE_ARM=1 ../.. \
|
||||
&& make -j $(nproc)
|
||||
@echo 'Successfully compiled for ARM'
|
||||
|
||||
aarch64:
|
||||
@echo 'Cross-Compiling for AARCH64'
|
||||
mkdir -p "build/$@" && cd "build/$@" \
|
||||
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-s" -DCMAKE_CXX_FLAGS="-s" \
|
||||
-DCROSS_COMPILE_AARCH64=1 ../.. \
|
||||
&& make -j $(nproc)
|
||||
@echo 'Successfully compiled for AARCH64'
|
||||
|
||||
armhf:
|
||||
@echo 'Cross-Compiling for ARMHF'
|
||||
mkdir -p "build/$@" && cd "build/$@" \
|
||||
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-s" -DCMAKE_CXX_FLAGS="-s" \
|
||||
-DCROSS_COMPILE_RPI_ARM=1 ../.. \
|
||||
&& make -j $(nproc)
|
||||
@echo 'Successfully compiled for ARMHF'
|
||||
|
||||
clean:
|
||||
@echo 'Removing all temporary files'
|
||||
git clean -ffxd
|
||||
|
||||
export_compile_commands:
|
||||
@echo 'Exporting CMake compile commands'
|
||||
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .
|
||||
git checkout HEAD -- Makefile
|
||||
|
||||
prepare:
|
||||
# if the system is Debian
|
||||
grep 'ID_LIKE=debian' /etc/os-release > /dev/null 2>&1 \
|
||||
&& echo 'Preparing dependencies for Debian' \
|
||||
&& export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y git build-essential cmake libasio-dev \
|
||||
g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf g++-aarch64-linux-gnu
|
||||
# mark directory safe for Git if running in container
|
||||
[ ! -z "${container}" ] && git config --global --add safe.directory \
|
||||
"$(abspath $(dir $(lastword $(MAKEFILE_LIST))))"
|
||||
@ -0,0 +1,140 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Name: DVM Host Configuration Annotator
|
||||
Creator: K4YT3X
|
||||
Date Created: April 1, 2023
|
||||
Last Modified: April 1, 2023
|
||||
|
||||
This script updates DVM Host's example config with the content of a modified one
|
||||
to generate a configuration with the settings of the modified config but with the
|
||||
config from the original example config.
|
||||
|
||||
Example usages:
|
||||
|
||||
1. Annotate a config file in-place using DVM Host's default config file:
|
||||
|
||||
`python config_annotator.py -em modified.yaml`
|
||||
|
||||
2. Annotate a config file using a custom template file and export it to a separate file:
|
||||
|
||||
`python config_annotator.py -t template.yml -m modified.yml -o annotated.yml`
|
||||
"""
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
|
||||
# since this stand-alone script does not have a pyproject.yaml or requirements.txt
|
||||
# prompt the user to install the required libraries if they're not found
|
||||
try:
|
||||
import requests
|
||||
import ruamel.yaml
|
||||
except ImportError:
|
||||
print(
|
||||
"Error: unable to import ruamel.yaml or requests\n"
|
||||
"Please install it with `pip install ruamel.yaml requests`",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
# URL to DVM Host's official example URL
|
||||
EXAMPLE_CONFIG_URL = (
|
||||
"https://github.com/DVMProject/dvmhost/raw/master/configs/config.example.yml"
|
||||
)
|
||||
|
||||
|
||||
def parse_arguments() -> argparse.Namespace:
|
||||
"""
|
||||
parse command line arguments
|
||||
|
||||
:return: parsed arguments in an argparse namespace object
|
||||
"""
|
||||
parser = argparse.ArgumentParser(description="Update a YAML file with new values.")
|
||||
template_group = parser.add_mutually_exclusive_group(required=True)
|
||||
template_group.add_argument(
|
||||
"-e",
|
||||
"--example",
|
||||
help="use DVM Host's default example config as template",
|
||||
action="store_true",
|
||||
)
|
||||
template_group.add_argument(
|
||||
"-t",
|
||||
"--template",
|
||||
type=Path,
|
||||
help="path to the template config YAML file with comments",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-m", "--modified", type=Path, help="path to the modified YAML file"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o", "--output", type=Path, help="path to the save the annotated YAML file"
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def update_dict(template_dict: Dict, modified_dict: Dict) -> Dict:
|
||||
"""
|
||||
Recursively updates the values of template_dict with the values of modified_dict,
|
||||
without changing the order of the keys in template_dict.
|
||||
|
||||
:param template_dict: the dictionary to update.
|
||||
:type template_dict: dict
|
||||
:param modified_dict: the dictionary with the updated values
|
||||
:type modified_dict: dict
|
||||
:return: the updated dictionary
|
||||
:rtype: dict
|
||||
"""
|
||||
for key, value in modified_dict.items():
|
||||
if isinstance(value, dict) and key in template_dict:
|
||||
update_dict(template_dict[key], value)
|
||||
elif key in template_dict:
|
||||
template_dict[key] = value
|
||||
return template_dict
|
||||
|
||||
|
||||
def main(
|
||||
example: bool, template_path: Path, modified_path: Path, output_path: Path
|
||||
) -> None:
|
||||
# if the example file is to be used
|
||||
# download it from the GitHub repo
|
||||
if example is True:
|
||||
response = requests.get(EXAMPLE_CONFIG_URL)
|
||||
response.raise_for_status()
|
||||
template_content = response.text
|
||||
|
||||
# if a custom template file is to be used
|
||||
else:
|
||||
with template_path.open(mode="r") as template_file:
|
||||
template_content = template_file.read()
|
||||
|
||||
# load the YAML file
|
||||
template = ruamel.yaml.YAML().load(template_content)
|
||||
|
||||
# load the modified YAML file
|
||||
with modified_path.open(mode="r") as modified_file:
|
||||
modified = ruamel.yaml.YAML().load(modified_file)
|
||||
|
||||
# update the template with the modified YAML data
|
||||
update_dict(template, modified)
|
||||
|
||||
# if no output file path is specified, write it back to the modified file
|
||||
if args.output is None:
|
||||
write_path = modified_path
|
||||
|
||||
# if an output file path has been specified, write the output to that file
|
||||
else:
|
||||
write_path = output_path
|
||||
|
||||
# write the updated YAML file back to disk
|
||||
with write_path.open(mode="w") as output_file:
|
||||
yaml = ruamel.yaml.YAML()
|
||||
|
||||
# set the output YAML file's indentation to 4 spaces per project standard
|
||||
yaml.indent(mapping=4, sequence=6, offset=4)
|
||||
yaml.dump(template, output_file)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_arguments()
|
||||
main(args.example, args.template, args.modified, args.output)
|
||||
Loading…
Reference in new issue