@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
--- |
||||
# Codacy exclusions for files that should not be analyzed. |
||||
# These paths are either vendored third-party content or generated code. |
||||
|
||||
exclude_paths: |
||||
# Vendored Cesium content. This code is maintained upstream and is not |
||||
# part of the SDRangel source code being developed in this repository. |
||||
- "plugins/feature/map/Cesium/**" |
||||
|
||||
# Generated Swagger UI files. These files are generated from the Swagger |
||||
# definition and should not be modified or analyzed as source code. |
||||
- "sdrbase/resources/webapi/doc/swagger-ui/**" |
||||
|
||||
# Generated Swagger documentation. The contents are generated from the |
||||
# API definition rather than maintained manually. |
||||
- "sdrbase/resources/webapi/doc/swagger/**" |
||||
|
||||
# Generated Swagger client code. This code is produced by the Swagger |
||||
# code generator and should not be analyzed as manually maintained code. |
||||
- "swagger/sdrangel/code/**" |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
Review SDRangel pull requests using the repository and current PR as context. |
||||
|
||||
Focus on finding real defects, regressions, compatibility problems, and relevant documentation inconsistencies in the changes being reviewed. Use repository-specific conventions and architecture only when they are relevant to the changed code. If everything looks OK, be as brief as possible. |
||||
|
||||
Focus on the current PR, not on producing general SDRangel documentation. |
||||
|
||||
Cover: |
||||
|
||||
- **PR context**: What the PR changes, which subsystems it affects, and any repository-specific context needed to review it correctly. |
||||
|
||||
- **Relevant architecture**: Describe only the SDRangel architecture relevant to the changed code. Use concrete concepts such as plugins, devices, channels, features, DSP components, GUI components, message queues, FIFOs, worker threads, or WebAPI where applicable. Do not force the code into generic patterns such as MVC, MVVM, or monorepo architecture. |
||||
|
||||
- **Relevant code structure**: Identify the classes, interfaces, directories, message types, queues, build files, generated code, or other components that matter to the PR. Do not describe unrelated parts of the repository. |
||||
|
||||
- **Inheritance and existing infrastructure**: Before reporting missing functionality in a derived class, inspect its base classes and inherited methods, slots, signals, constructors, and established initialization paths. Do not request derived-class implementations when the required behavior is already provided by inherited code. |
||||
|
||||
- **Relevant dependencies and tooling**: Mention Qt, CMake, external libraries, hardware APIs, generated code, CI, static analysis, sanitizers, or other tooling only when relevant to the PR. |
||||
|
||||
- **Testing and validation**: SDRangel does not have an established unit-test or automated regression-test framework for its DSP, device, channel, feature, or GUI code. Do not request, recommend, or criticize a PR for missing unit tests, regression tests, test fixtures, or new test infrastructure. Do not turn manual validation requirements into requests to write automated tests. Compilation, CI, cppcheck, Coverity, OpenGrep, sanitizers, and similar automated checks are not testing recommendations for the PR review. Instead, identify appropriate directed manual validation for the actual changes, using SDRangel, relevant features, devices, signal sources, hardware, WebAPI, or existing operational workflows as appropriate. Manual test scenarios are valid review guidance; requests to implement those scenarios as automated tests are not. |
||||
|
||||
- **Testing expectations**: Review whether the changed behavior can be meaningfully validated through the project's existing manual testing practices. The absence of an automated test framework is not a deficiency and must not be presented as a reason to add one. When validation is relevant, describe the concrete manual scenario to perform rather than suggesting automated test development. |
||||
|
||||
- **No automated-test recommendations**: Never add a “Test suggestions” section recommending unit tests, regression tests, automated verification, test harnesses, or new testing infrastructure for SDRangel source changes. If validation is appropriate, describe the concrete **manual test scenario** the contributor or reviewer should perform instead. For example, say “Manually verify VHF DSC demodulation with 1300/2100 Hz tones” rather than “Unit test VHF DSC demodulation.” Do not convert each manual validation scenario into a separate automated-test recommendation. |
||||
|
||||
- **Relevant conventions and pitfalls**: Identify established SDRangel conventions and concrete risks relevant to the changed code, such as thread/lifetime races, message ownership, queue handling, startup/shutdown ordering, Qt ownership, DSP/device lifecycle, settings serialization, API compatibility, generated code, or CMake dependencies. Only include issues relevant to the PR. |
||||
|
||||
- **Scope discipline**: Review the changes in the PR rather than looking for unrelated existing issues. Do not report pre-existing problems unless the PR introduces, exposes, or materially changes them. |
||||
|
||||
- **Documentation consistency**: Use relevant repository documentation, developer notes, and wiki material as review context. Assume the current code is authoritative when documentation or wiki content disagrees with it. Do not flag correct code merely because it differs from stale documentation. Instead, point out the documentation discrepancy when the PR changes or exposes behavior that is documented incorrectly or incompletely. Do not require documentation changes for purely internal implementation changes. |
||||
|
||||
- **Generated and third-party code**: Identify generated, vendored, or externally maintained code relevant to the PR. Do not apply normal SDRangel source-review expectations to such code unless the PR intentionally modifies or integrates it. |
||||
|
||||
- **Out of scope**: Do not request unrelated refactoring, broad modernization, new abstractions, architectural redesign, new automated tests, new test infrastructure, or generic best-practice changes. Do not flag missing unit or regression tests when they are not an established requirement for the affected code. |
||||
|
||||
Rules: |
||||
Rules: |
||||
- Output only the Markdown content, with no preamble or explanation. |
||||
- Be concise. Every line should earn its place. |
||||
- Prefer concrete, actionable findings tied to changed code over speculative concerns or hypothetical future problems. |
||||
- Use short sections and bullets. |
||||
- Make the result specific to reviewing this PR, not a generic SDRangel architecture document. |
||||
- Before reporting a defect involving an existing class, method, or API, inspect its implementation and relevant callers when necessary to establish its actual behavior. Follow relevant ownership, lifetime, locking, cleanup, synchronization, inheritance, virtual methods, signals, slots, and initialization paths outside the diff. Do not infer behavior or missing functionality from method names, types, or changed code alone. |
||||
- Review changed code in the context of the actual repository implementation, including code outside the PR when it defines the behavior of changed code. Use that code to determine whether the PR introduces a defect, but do not report unrelated pre-existing issues. |
||||
- Base statements on actual repository code, documentation, and established project practices. |
||||
- Do not invent requirements or impose generic software-engineering practices. |
||||
- Do not recommend or request automated tests, unit tests, regression tests, test harnesses, or new test infrastructure. SDRangel does not have an automated test framework, and the absence of one is not a defect or a review finding. |
||||
- Never add a generic “Test suggestions” section solely because a PR lacks automated tests. |
||||
- Omit sections that are not relevant to the PR. |
||||
- When code and documentation disagree, do not assume the code is wrong. Treat the discrepancy as a documentation issue unless there is independent evidence of a code defect. |
||||
@ -1 +1,48 @@
@@ -1 +1,48 @@
|
||||
*.fits binary |
||||
# Git attributes for SDRangel |
||||
# normalize text files to LF and identify binary files. |
||||
* text=auto eol=lf |
||||
|
||||
# Vendored Cesium content: preserve upstream line endings. |
||||
plugins/feature/map/Cesium/** -text |
||||
|
||||
# Generated Swagger UI files |
||||
sdrbase/resources/webapi/doc/swagger-ui/** -text |
||||
|
||||
# Generated Swagger documentation and client code |
||||
sdrbase/resources/webapi/doc/swagger/** -text |
||||
swagger/sdrangel/code/** -text |
||||
|
||||
# SDRangel configuration and preset files |
||||
*.cfgx binary |
||||
*.prex binary |
||||
|
||||
# Binary image files. |
||||
*.png binary |
||||
*.PNG binary |
||||
*.bmp binary |
||||
*.BMP binary |
||||
*.xcf binary |
||||
*.XCF binary |
||||
*.jpg binary |
||||
*.JPG binary |
||||
*.fits binary |
||||
*.FITS binary |
||||
*.ico binary |
||||
*.ICO binary |
||||
*.icns binary |
||||
*.icns binary |
||||
*.gif binary |
||||
*.GIF binary |
||||
|
||||
# Binary audio/media files. |
||||
*.wav binary |
||||
*.WAV binary |
||||
*.wasm binary |
||||
*.WASM binary |
||||
|
||||
# Binary fonts. |
||||
*.ttf binary |
||||
*.TTF binary |
||||
|
||||
# Binary document files. |
||||
*.odg binary |
||||
|
||||
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh |
||||
|
||||
#fail if trailing spaces |
||||
if ! git diff --cached --check -- \ |
||||
':(attr:text)' ':(attr:text=auto)'; then |
||||
echo "Error: Remove trailing whitespace from staged changes." |
||||
exit 1 |
||||
fi |
||||
@ -0,0 +1,276 @@
@@ -0,0 +1,276 @@
|
||||
#!/bin/bash |
||||
# Loosely based off https://github.com/the-tcpdump-group/libpcap/blob/master/.ci-coverity-scan-build.sh |
||||
# which is based off a script coverity released https://scan.coverity.com/download |
||||
|
||||
if [ -z "${BASH_VERSION:-}" ]; then |
||||
echo "ERROR: This script must be run with bash" |
||||
exit 1 |
||||
fi |
||||
|
||||
set_output() |
||||
{ |
||||
if [ -n "${GITHUB_OUTPUT:-}" ]; then |
||||
echo "$1" >> "$GITHUB_OUTPUT" |
||||
else |
||||
echo "$1" |
||||
fi |
||||
} |
||||
|
||||
set -euo pipefail |
||||
|
||||
if [[ $- == *x* ]]; then |
||||
echo "ERROR: bash xtrace (-x) is enabled and that might expose COVERITY_SCAN_TOKEN" >&2 |
||||
exit 1 |
||||
fi |
||||
|
||||
PRECHECK=false |
||||
if [ "${1:-}" = "--precheck" ]; then |
||||
PRECHECK=true |
||||
fi |
||||
|
||||
# Environment check |
||||
if [ -z "${COVERITY_SCAN_PROJECT_NAME:-}" ] || |
||||
[ -z "${COVERITY_SCAN_PROJECT_ID:-}" ] || |
||||
[ -z "${COVERITY_SCAN_NOTIFICATION_EMAIL:-}" ] || |
||||
[ -z "${COVERITY_SCAN_TOKEN:-}" ]; then |
||||
printf "\033[33;1mNote: COVERITY_SCAN_PROJECT_NAME, COVERITY_SCAN_PROJECT_ID, COVERITY_SCAN_TOKEN are available on the Project Settings page on scan.coverity.com\033[0m\n" |
||||
|
||||
[ -z "${COVERITY_SCAN_PROJECT_NAME:-}" ] && echo "ERROR: COVERITY_SCAN_PROJECT_NAME must be set" |
||||
[ -z "${COVERITY_SCAN_PROJECT_ID:-}" ] && echo "ERROR: COVERITY_SCAN_PROJECT_ID must be set" |
||||
[ -z "${COVERITY_SCAN_NOTIFICATION_EMAIL:-}" ] && echo "ERROR: COVERITY_SCAN_NOTIFICATION_EMAIL must be set" |
||||
[ -z "${COVERITY_SCAN_TOKEN:-}" ] && echo "ERROR: COVERITY_SCAN_TOKEN must be set" |
||||
|
||||
exit 1 |
||||
fi |
||||
|
||||
REQUIRED_TOOLS=("curl" "git" "sed" "paste" "tar" "ruby" "md5sum" "jq") |
||||
for tool in "${REQUIRED_TOOLS[@]}"; do |
||||
if ! command -v "$tool" >/dev/null 2>&1; then |
||||
echo "ERROR: Required system tool '$tool' is not installed or available in PATH." >&2 |
||||
exit 1 |
||||
fi |
||||
done |
||||
|
||||
PLATFORM=$(uname) |
||||
TOOL_ARCHIVE=/tmp/cov-analysis-${PLATFORM}.tgz |
||||
TOOL_URL=https://scan.coverity.com/download/linux64 |
||||
TOOL_BASE=/tmp/coverity-scan-analysis |
||||
SCAN_URL="https://scan.coverity.com" |
||||
JOBS=$(( $(nproc) - 2 )) |
||||
[ "$JOBS" -lt 1 ] && JOBS=1 |
||||
|
||||
# Safely locate the repository root directory relative to this script |
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" |
||||
CMAKE_FILE="$REPO_ROOT/CMakeLists.txt" |
||||
if [ ! -f "$CMAKE_FILE" ]; then |
||||
echo "ERROR: CAN NOT FIND CMakeLists.txt" |
||||
exit 1 |
||||
fi |
||||
|
||||
SHA=$(git -C "$REPO_ROOT" rev-parse --short HEAD) |
||||
VERSION_SHA=$(sed -nE \ |
||||
's/^set\(sdrangel_VERSION_(MAJOR|MINOR|PATCH) "([^"]+)".*/\2/p' \ |
||||
"$CMAKE_FILE" | paste -sd.)"-g${SHA}" |
||||
|
||||
COVERITY_VERSION=$(curl -s "https://scan.coverity.com/projects/${COVERITY_SCAN_PROJECT_NAME//\//-}" | |
||||
grep "Version:" | \ |
||||
sed -e 's/<[^>]*>//g' -e 's/Version://' -e 's/^[ \t]*//' -e 's/[ \t]*$//') |
||||
|
||||
echo "Coverity Remote Version: '$COVERITY_VERSION'" |
||||
echo "Local Code Version: '$VERSION_SHA'" |
||||
|
||||
if [ "$COVERITY_VERSION" = "$VERSION_SHA" ]; then |
||||
printf "\033[33;1mCoverity matches current branch head, no need to analyze.\033[0m\n" |
||||
if [ "$PRECHECK" = true ]; then |
||||
set_output "run=false" |
||||
fi |
||||
exit 0 |
||||
fi |
||||
printf "\033[33;1mCoverity is out of date. Progressing to analyze and upload\033[0m\n" |
||||
|
||||
# Verify upload is permitted |
||||
AUTH_RES=$(curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted) |
||||
if [ "$AUTH_RES" = "Access denied" ]; then |
||||
printf "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m\n" |
||||
if [ "$PRECHECK" = true ]; then |
||||
set_output "run=false" |
||||
fi |
||||
exit 1 |
||||
fi |
||||
|
||||
AUTH=$(echo "$AUTH_RES" | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['upload_permitted']") |
||||
if [ "$AUTH" = "true" ]; then |
||||
printf "\033[33;1mCoverity Scan analysis authorized per quota.\033[0m\n" |
||||
if [ "$PRECHECK" = true ]; then |
||||
set_output "run=true" |
||||
exit 0 |
||||
fi |
||||
else |
||||
WHEN=$(echo "$AUTH_RES" | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['next_upload_permitted_at']") |
||||
printf "\033[33;1mCoverity Scan analysis NOT authorized until %s.\033[0m\n" "$WHEN" |
||||
if [ "$PRECHECK" = true ]; then |
||||
set_output "run=false" |
||||
fi |
||||
exit 0 |
||||
fi |
||||
|
||||
if command -v cov-build >/dev/null 2>&1; then |
||||
printf "\033[33;1mUsing existing Coverity Build Tool\033[0m\n " |
||||
command -v cov-build |
||||
else |
||||
if [ ! -d $TOOL_BASE ]; then |
||||
# Download Coverity Scan Analysis Tool |
||||
if [ ! -e "$TOOL_ARCHIVE" ]; then |
||||
printf "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m\n" |
||||
curl --data-urlencode "project=$COVERITY_SCAN_PROJECT_NAME" \ |
||||
--data-urlencode "token=$COVERITY_SCAN_TOKEN" \ |
||||
"$TOOL_URL" -o "$TOOL_ARCHIVE" |
||||
stat "$TOOL_ARCHIVE" |
||||
|
||||
curl --data-urlencode "project=$COVERITY_SCAN_PROJECT_NAME" \ |
||||
--data-urlencode "token=$COVERITY_SCAN_TOKEN" \ |
||||
--data-urlencode "md5=1" \ |
||||
"$TOOL_URL" -o "${TOOL_ARCHIVE}.md5" |
||||
|
||||
stat "${TOOL_ARCHIVE}.md5" |
||||
cat "${TOOL_ARCHIVE}.md5" |
||||
md5sum "$TOOL_ARCHIVE" |
||||
echo "$(cat "${TOOL_ARCHIVE}.md5")" "$TOOL_ARCHIVE" | md5sum -c |
||||
fi |
||||
|
||||
# Extract Coverity Scan Analysis Tool |
||||
printf "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m\n" |
||||
mkdir -p $TOOL_BASE |
||||
tar xzf "$TOOL_ARCHIVE" -C "$TOOL_BASE" |
||||
fi |
||||
|
||||
TOOL_DIR=$(find $TOOL_BASE -type d -name 'cov-analysis*') |
||||
export PATH="$TOOL_DIR/bin:$PATH" |
||||
fi |
||||
|
||||
COVERITY_TOOL_VERSION=$( |
||||
cov-build version 2>&1 | |
||||
sed -n '1p' | |
||||
sed -E 's/.* version ([^ ]+) .*/\1/' || |
||||
true |
||||
) |
||||
|
||||
if [ -z "$COVERITY_TOOL_VERSION" ]; then |
||||
echo "ERROR: Unable to determine Coverity Build Capture version." >&2 |
||||
exit 1 |
||||
fi |
||||
|
||||
printf "\033[33;1mCoverity Build Capture version: %s\033[0m\n" "$COVERITY_TOOL_VERSION" |
||||
|
||||
# Configure |
||||
RESULTS_DIR="$REPO_ROOT/cov-int" |
||||
BUILD_DIR="$REPO_ROOT/build-coverity" |
||||
RESULTS_ARCHIVE="$REPO_ROOT/analysis-results.tgz" |
||||
cd "$REPO_ROOT" || { |
||||
echo "ERROR: Unable to change to repository root: $REPO_ROOT" >&2 |
||||
exit 1 |
||||
} |
||||
|
||||
if [ ! -f "$RESULTS_ARCHIVE" ] ; then |
||||
rm -rf "$RESULTS_DIR" |
||||
rm -rf "$BUILD_DIR" |
||||
|
||||
cmake -S "$REPO_ROOT" \ |
||||
-B "$BUILD_DIR" \ |
||||
-G Ninja \ |
||||
-DENABLE_LTO=OFF -DENABLE_CCACHE=OFF |
||||
|
||||
# Build |
||||
printf "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m\n" |
||||
|
||||
cov-build --dir "$RESULTS_DIR" ninja -C "$BUILD_DIR" -j "$JOBS" |
||||
if grep -q "No files were emitted." "$RESULTS_DIR/build-log.txt"; then |
||||
echo "ERROR: Coverity did not emit any files." >&2 |
||||
exit 1 |
||||
fi |
||||
# Collects change data for source files from the SCM. |
||||
cov-import-scm --dir "$RESULTS_DIR" --scm git --log "$RESULTS_DIR/scm_log.txt" 2>&1 |
||||
|
||||
# Upload results |
||||
printf "\033[33;1mTarring Coverity Scan Analysis results...\033[0m\n" |
||||
tar czf "$RESULTS_ARCHIVE" -C "$REPO_ROOT" cov-int |
||||
fi |
||||
|
||||
if ! tar tf "$RESULTS_ARCHIVE" | grep '^cov-int/build-log.txt$' >/dev/null; then |
||||
echo "ERROR: Coverity archive $RESULTS_ARCHIVE does not contain cov-int/build-log.txt" >&2 |
||||
exit 1 |
||||
fi |
||||
|
||||
RESULTS_SIZE=$(stat -c '%s' "$RESULTS_ARCHIVE") |
||||
RESULTS_SIZE_MB=$((RESULTS_SIZE / 1024 / 1024)) |
||||
printf "\033[33;1mCoverity results archive: %d MB\033[0m\n" "$RESULTS_SIZE_MB" |
||||
|
||||
# Verify Coverity Scan script test mode |
||||
if [ "${coverity_scan_script_test_mode:-false}" = true ]; then |
||||
printf "\033[33;1mCoverity Scan configured in script test mode. Exit.\033[0m\n" |
||||
exit 0 |
||||
fi |
||||
|
||||
if [ "$RESULTS_SIZE" -gt "$((500 * 1024 * 1024))" ]; then |
||||
printf "\033[33;1mUploading Large Coverity Scan Analysis results...\033[0m\n" |
||||
# Step 1: Initialize build |
||||
INIT_RESPONSE=$(curl \ |
||||
--fail \ |
||||
--show-error \ |
||||
--request POST \ |
||||
--data-urlencode "version=$VERSION_SHA" \ |
||||
--data-urlencode "description=Automated Build: $VERSION_SHA" \ |
||||
--data-urlencode "email=$COVERITY_SCAN_NOTIFICATION_EMAIL" \ |
||||
--data-urlencode "token=$COVERITY_SCAN_TOKEN" \ |
||||
--data-urlencode "file_name=$(basename "$RESULTS_ARCHIVE")" \ |
||||
"$SCAN_URL/projects/$COVERITY_SCAN_PROJECT_ID/builds/init") |
||||
|
||||
UPLOAD_URL=$(echo "$INIT_RESPONSE" | jq -r '.url') |
||||
BUILD_ID=$(echo "$INIT_RESPONSE" | jq -r '.build_id') |
||||
|
||||
if [ -z "$UPLOAD_URL" ] || [ "$UPLOAD_URL" = "null" ]; then |
||||
echo "ERROR: Coverity did not return an upload URL." >&2 |
||||
exit 1 |
||||
fi |
||||
|
||||
if [ -z "$BUILD_ID" ] || [ "$BUILD_ID" = "null" ]; then |
||||
echo "ERROR: Coverity did not return a build ID." >&2 |
||||
exit 1 |
||||
fi |
||||
|
||||
# Step 2: Upload to cloud |
||||
curl \ |
||||
--fail \ |
||||
--show-error \ |
||||
--request PUT \ |
||||
--header 'Content-Type: application/json' \ |
||||
--upload-file "$RESULTS_ARCHIVE" \ |
||||
"$UPLOAD_URL" |
||||
|
||||
# Step 3: Enqueue build |
||||
curl \ |
||||
--fail \ |
||||
--show-error \ |
||||
--request PUT \ |
||||
--data-urlencode "token=$COVERITY_SCAN_TOKEN" \ |
||||
"$SCAN_URL/projects/$COVERITY_SCAN_PROJECT_ID/builds/$BUILD_ID/enqueue" |
||||
else |
||||
printf "\033[33;1mUploading Coverity Scan Analysis results...\033[0m\n" |
||||
UPLOAD_URL="https://scan.coverity.com/builds" |
||||
response=$(curl \ |
||||
--silent --write-out "\n%{http_code}\n" \ |
||||
--form project="$COVERITY_SCAN_PROJECT_NAME" \ |
||||
--form token="$COVERITY_SCAN_TOKEN" \ |
||||
--form "email=$COVERITY_SCAN_NOTIFICATION_EMAIL" \ |
||||
--form "file=@$RESULTS_ARCHIVE" \ |
||||
--form version="$VERSION_SHA" \ |
||||
--form description="Automated Build: $VERSION_SHA" \ |
||||
$UPLOAD_URL) |
||||
status_code=$(echo "$response" | sed -n '$p') |
||||
if [ "$status_code" != "200" ] && [ "$status_code" != "201" ]; then |
||||
TEXT=$(echo "$response" | sed '$d') |
||||
printf "\033[33;1mCoverity Scan upload failed with HTTP status code '%s': %s.\033[0m\n" "$status_code" "$TEXT" |
||||
exit 1 |
||||
fi |
||||
fi |
||||
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
name: SDRangel Linux Coverity build |
||||
|
||||
# Run every day at 3:00am UTC |
||||
on: |
||||
schedule: |
||||
- cron: '0 3 * * *' |
||||
workflow_dispatch: |
||||
|
||||
jobs: |
||||
build_coverity: |
||||
if: github.repository == 'f4exb/sdrangel' |
||||
# run once on latest |
||||
runs-on: ubuntu-24.04 |
||||
env: |
||||
COVERITY_SCAN_PROJECT_NAME: ${{ github.repository }} |
||||
COVERITY_SCAN_PROJECT_ID : "33161" |
||||
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }} |
||||
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
with: |
||||
submodules: true |
||||
fetch-depth: 0 |
||||
- name: Check Coverity |
||||
id: coverity_check |
||||
run: | |
||||
./.github/workflows/coverity.sh --precheck |
||||
# keep dependencies synced with linux.yml |
||||
- name: Install dependencies |
||||
if: steps.coverity_check.outputs.run == 'true' |
||||
run: | |
||||
sudo apt-get update |
||||
sudo apt-get install software-properties-common |
||||
sudo add-apt-repository -y ppa:ettusresearch/uhd |
||||
sudo apt-get update |
||||
sudo apt-get -y install build-essential cmake git xxd \ |
||||
devscripts fakeroot debhelper libfftw3-dev qtbase5-dev libopengl-dev libqt5opengl5-dev \ |
||||
qttools5-dev qttools5-dev-tools qtmultimedia5-dev libqt5multimedia5-plugins libqt5websockets5-dev \ |
||||
libqt5quick5 qtwebengine5-dev qtbase5-private-dev \ |
||||
qml-module-qtlocation qml-module-qtpositioning qml-module-qtquick-window2 qml-module-qtquick-dialogs \ |
||||
qml-module-qtquick-controls qml-module-qtquick-controls2 qml-module-qtquick-layouts qml-module-qtgraphicaleffects \ |
||||
libqt5serialport5-dev qtdeclarative5-dev qtpositioning5-dev qtlocation5-dev \ |
||||
libqt5charts5-dev libqt5texttospeech5-dev libqt5gamepad5-dev libqt5svg5-dev libfaad-dev libflac-dev zlib1g-dev \ |
||||
libusb-1.0-0-dev libhidapi-dev libboost-all-dev libasound2-dev libopencv-dev libopencv-imgcodecs-dev \ |
||||
libxml2-dev bison flex ffmpeg libpostproc-dev libavcodec-dev libavformat-dev libavfilter-dev \ |
||||
libopus-dev libcodec2-dev libairspy-dev libhackrf-dev \ |
||||
libbladerf-dev libsoapysdr-dev libiio-dev libuhd-dev libhamlib-dev libunwind-dev \ |
||||
libavahi-client-dev libavahi-common-dev libaio-dev \ |
||||
python3-mako python3-cheetah python3-numpy \ |
||||
autoconf automake libtool ninja-build |
||||
bash cmake/ci/build_sdrplay.sh |
||||
- name: Build SDRangel for Coverity |
||||
if: steps.coverity_check.outputs.run == 'true' |
||||
run: | |
||||
./.github/workflows/coverity.sh |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
name: Check Git attributes |
||||
|
||||
on: |
||||
pull_request: |
||||
|
||||
jobs: |
||||
check-gitattributes: |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
with: |
||||
fetch-depth: 0 |
||||
|
||||
- name: Check for line ending violations |
||||
run: | |
||||
# Re-normalize all files according to .gitattributes |
||||
git add --renormalize . |
||||
|
||||
# Check if renormalization changed anything |
||||
if git diff --cached --name-only | grep -q .; then |
||||
echo "::error::The following files have line endings that don't match .gitattributes settings:" |
||||
git diff --cached --name-only |
||||
echo "" |
||||
echo "To fix, run:" |
||||
echo " git add --renormalize ." |
||||
echo " git commit -m 'Normalize line endings'" |
||||
exit 1 |
||||
fi |
||||
|
||||
echo "All files have correct line endings." |
||||
|
||||
- name: Check for trailing whitespace |
||||
run: | |
||||
if ! git diff --check \ |
||||
"${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}" \ |
||||
-- ':(attr:text)' ':(attr:text=auto)'; then |
||||
echo "::error::Trailing whitespace found in the pull request." |
||||
echo "Remove trailing spaces and tabs from added lines." |
||||
exit 1 |
||||
fi |
||||
|
||||
echo "No trailing whitespace found in the pull request." |
||||
@ -1,75 +1,76 @@
@@ -1,75 +1,76 @@
|
||||
name: SDRangel Linux release build |
||||
|
||||
on: |
||||
push: |
||||
branches: |
||||
- linux_github_release |
||||
tags: |
||||
- 'v*' |
||||
workflow_dispatch: |
||||
|
||||
jobs: |
||||
build_deb: |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: [ubuntu-22.04, ubuntu-24.04] |
||||
runs-on: ${{ matrix.os }} |
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
with: |
||||
submodules: true |
||||
fetch-depth: 0 |
||||
- name: Install dependencies |
||||
run: | |
||||
sudo apt-get update |
||||
sudo apt-get install software-properties-common |
||||
sudo add-apt-repository -y ppa:ettusresearch/uhd |
||||
sudo apt-get update |
||||
sudo apt-get -y install build-essential cmake git xxd \ |
||||
devscripts fakeroot debhelper libfftw3-dev qtbase5-dev libopengl-dev libqt5opengl5-dev \ |
||||
qttools5-dev qttools5-dev-tools qtmultimedia5-dev libqt5multimedia5-plugins libqt5websockets5-dev \ |
||||
libqt5quick5 qtwebengine5-dev qtbase5-private-dev \ |
||||
qml-module-qtlocation qml-module-qtpositioning qml-module-qtquick-window2 qml-module-qtquick-dialogs \ |
||||
qml-module-qtquick-controls qml-module-qtquick-controls2 qml-module-qtquick-layouts qml-module-qtgraphicaleffects \ |
||||
libqt5serialport5-dev qtdeclarative5-dev qtpositioning5-dev qtlocation5-dev \ |
||||
libqt5charts5-dev libqt5texttospeech5-dev libqt5gamepad5-dev libqt5svg5-dev libfaad-dev libflac-dev zlib1g-dev \ |
||||
libusb-1.0-0-dev libhidapi-dev libboost-all-dev libasound2-dev libopencv-dev libopencv-imgcodecs-dev \ |
||||
libxml2-dev bison flex ffmpeg libpostproc-dev libavcodec-dev libavformat-dev \ |
||||
libopus-dev libcodec2-dev libairspy-dev libhackrf-dev \ |
||||
libbladerf-dev libsoapysdr-dev libiio-dev libuhd-dev libhamlib-dev libunwind-dev \ |
||||
libavahi-client-dev libavahi-common-dev libaio-dev \ |
||||
python3-mako python3-cheetah python3-numpy \ |
||||
autoconf automake libtool ninja-build |
||||
bash cmake/ci/build_sdrplay.sh |
||||
- name: Build SDRangel |
||||
run: | |
||||
if [ "${RUNNING_IN_ACT:-}" = "true" ]; then |
||||
mkdir -p /tmp/build |
||||
rsync -a --delete . /tmp/build/sdrangel/ |
||||
cd /tmp/build/sdrangel |
||||
debuild -i -us -uc -b |
||||
cp ../sdrangel_*_amd64.deb "$GITHUB_WORKSPACE"/ |
||||
else |
||||
debuild -i -us -uc -b |
||||
fi |
||||
- name: Get version |
||||
id: get_version |
||||
run: | |
||||
if [[ "${{github.ref_name}}" == "linux_github_release" ]]; then |
||||
echo "version=$(echo ${{github.sha}} | cut -c1-7)" >> $GITHUB_OUTPUT |
||||
else |
||||
echo "version=$(echo ${{github.ref_name}} | cut -c2-)" >> $GITHUB_OUTPUT |
||||
fi |
||||
- name: Rename |
||||
run: mv ../sdrangel_*_amd64.deb sdrangel_${{ steps.get_version.outputs.version }}_${{ matrix.os }}_amd64.deb |
||||
- name: Upload artifact |
||||
uses: actions/upload-artifact@v4 |
||||
with: |
||||
name: sdrangel_${{ steps.get_version.outputs.version }}_${{ matrix.os }}_amd64.deb |
||||
path: sdrangel_${{ steps.get_version.outputs.version }}_${{ matrix.os }}_amd64.deb |
||||
- name: Upload release |
||||
if: startsWith(github.ref, 'refs/tags/') |
||||
uses: softprops/action-gh-release@v2 |
||||
with: |
||||
files: sdrangel_${{ steps.get_version.outputs.version }}_${{ matrix.os }}_amd64.deb |
||||
name: SDRangel Linux release build |
||||
|
||||
on: |
||||
push: |
||||
branches: |
||||
- linux_github_release |
||||
tags: |
||||
- 'v*' |
||||
workflow_dispatch: |
||||
|
||||
jobs: |
||||
build_deb: |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: [ubuntu-22.04, ubuntu-24.04] |
||||
runs-on: ${{ matrix.os }} |
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
with: |
||||
submodules: true |
||||
fetch-depth: 0 |
||||
- name: Install dependencies |
||||
# ensure changes in dependencies get added to coverity.yml |
||||
run: | |
||||
sudo apt-get update |
||||
sudo apt-get install software-properties-common |
||||
sudo add-apt-repository -y ppa:ettusresearch/uhd |
||||
sudo apt-get update |
||||
sudo apt-get -y install build-essential cmake git xxd \ |
||||
devscripts fakeroot debhelper libfftw3-dev qtbase5-dev libopengl-dev libqt5opengl5-dev \ |
||||
qttools5-dev qttools5-dev-tools qtmultimedia5-dev libqt5multimedia5-plugins libqt5websockets5-dev \ |
||||
libqt5quick5 qtwebengine5-dev qtbase5-private-dev \ |
||||
qml-module-qtlocation qml-module-qtpositioning qml-module-qtquick-window2 qml-module-qtquick-dialogs \ |
||||
qml-module-qtquick-controls qml-module-qtquick-controls2 qml-module-qtquick-layouts qml-module-qtgraphicaleffects \ |
||||
libqt5serialport5-dev qtdeclarative5-dev qtpositioning5-dev qtlocation5-dev \ |
||||
libqt5charts5-dev libqt5texttospeech5-dev libqt5gamepad5-dev libqt5svg5-dev libfaad-dev libflac-dev zlib1g-dev \ |
||||
libusb-1.0-0-dev libhidapi-dev libboost-all-dev libasound2-dev libopencv-dev libopencv-imgcodecs-dev \ |
||||
libxml2-dev bison flex ffmpeg libpostproc-dev libavcodec-dev libavformat-dev libavfilter-dev \ |
||||
libopus-dev libcodec2-dev libairspy-dev libhackrf-dev \ |
||||
libbladerf-dev libsoapysdr-dev libiio-dev libuhd-dev libhamlib-dev libunwind-dev \ |
||||
libavahi-client-dev libavahi-common-dev libaio-dev \ |
||||
python3-mako python3-cheetah python3-numpy \ |
||||
autoconf automake libtool ninja-build |
||||
bash cmake/ci/build_sdrplay.sh |
||||
- name: Build SDRangel |
||||
run: | |
||||
if [ "${RUNNING_IN_ACT:-}" = "true" ]; then |
||||
mkdir -p /tmp/build |
||||
rsync -a --delete . /tmp/build/sdrangel/ |
||||
cd /tmp/build/sdrangel |
||||
debuild -i -us -uc -b |
||||
cp ../sdrangel_*_amd64.deb "$GITHUB_WORKSPACE"/ |
||||
else |
||||
debuild -i -us -uc -b |
||||
fi |
||||
- name: Get version |
||||
id: get_version |
||||
run: | |
||||
if [[ "${{github.ref_name}}" == "linux_github_release" ]]; then |
||||
echo "version=$(echo ${{github.sha}} | cut -c1-7)" >> $GITHUB_OUTPUT |
||||
else |
||||
echo "version=$(echo ${{github.ref_name}} | cut -c2-)" >> $GITHUB_OUTPUT |
||||
fi |
||||
- name: Rename |
||||
run: mv ../sdrangel_*_amd64.deb sdrangel_${{ steps.get_version.outputs.version }}_${{ matrix.os }}_amd64.deb |
||||
- name: Upload artifact |
||||
uses: actions/upload-artifact@v4 |
||||
with: |
||||
name: sdrangel_${{ steps.get_version.outputs.version }}_${{ matrix.os }}_amd64.deb |
||||
path: sdrangel_${{ steps.get_version.outputs.version }}_${{ matrix.os }}_amd64.deb |
||||
- name: Upload release |
||||
if: startsWith(github.ref, 'refs/tags/') |
||||
uses: softprops/action-gh-release@v2 |
||||
with: |
||||
files: sdrangel_${{ steps.get_version.outputs.version }}_${{ matrix.os }}_amd64.deb |
||||
|
||||
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
name: Packet Demod regression tests |
||||
|
||||
on: |
||||
pull_request: |
||||
paths: |
||||
- 'plugins/channelrx/demodpacket/**' |
||||
- 'sdrbase/dsp/**' |
||||
- 'sdrbase/util/**' |
||||
- '.github/workflows/packet-demod.yml' |
||||
push: |
||||
paths: |
||||
- 'plugins/channelrx/demodpacket/**' |
||||
- '.github/workflows/packet-demod.yml' |
||||
workflow_dispatch: |
||||
|
||||
permissions: |
||||
contents: read |
||||
|
||||
jobs: |
||||
dsp: |
||||
runs-on: ubuntu-24.04 |
||||
strategy: |
||||
matrix: |
||||
include: |
||||
- qt: 5 |
||||
package: qtbase5-dev |
||||
- qt: 6 |
||||
package: qt6-base-dev |
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
- run: sudo apt-get update && sudo apt-get install -y ninja-build ${{ matrix.package }} |
||||
- run: >- |
||||
cmake -S plugins/channelrx/demodpacket/tests -B build-packet-tests -G Ninja |
||||
-DCMAKE_BUILD_TYPE=Debug -DPACKET_TEST_SANITIZERS=ON |
||||
-DQT_DIR=/usr/lib/x86_64-linux-gnu/cmake/Qt${{ matrix.qt }} |
||||
- run: cmake --build build-packet-tests --parallel 2 |
||||
- run: ctest --test-dir build-packet-tests --output-on-failure |
||||
env: |
||||
UBSAN_OPTIONS: halt_on_error=1 |
||||
|
||||
plugin: |
||||
runs-on: ubuntu-24.04 |
||||
strategy: |
||||
matrix: |
||||
include: |
||||
- qt: 5 |
||||
enable_qt6: 'OFF' |
||||
packages: >- |
||||
qtbase5-dev qtbase5-private-dev qtmultimedia5-dev |
||||
libqt5websockets5-dev qtpositioning5-dev libqt5charts5-dev |
||||
libqt5serialport5-dev |
||||
- qt: 6 |
||||
enable_qt6: 'ON' |
||||
packages: >- |
||||
qt6-base-dev qt6-base-private-dev qt6-multimedia-dev |
||||
qt6-websockets-dev qt6-positioning-dev qt6-charts-dev |
||||
qt6-serialport-dev |
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
- name: Install dependencies |
||||
run: | |
||||
sudo apt-get update |
||||
sudo apt-get install -y ninja-build ${{ matrix.packages }} \ |
||||
libfftw3-dev libusb-1.0-0-dev libflac-dev \ |
||||
libboost-dev libopus-dev |
||||
- name: Configure server plugin and integration test |
||||
run: >- |
||||
cmake -S . -B build-packet-server -G Ninja -DCMAKE_BUILD_TYPE=Release |
||||
-DENABLE_QT6=${{ matrix.enable_qt6 }} |
||||
-DBUILD_GUI=OFF -DBUILD_SERVER=ON -DBUILD_BENCH=OFF |
||||
-DENABLE_EXTERNAL_LIBRARIES=OFF -DENABLE_LIBUNWIND=OFF |
||||
-DENABLE_FEATURE=OFF -DENABLE_CHANNELTX=OFF -DENABLE_CHANNELMIMO=OFF |
||||
-DPACKETDEMOD_BUILD_TESTS=ON -DPACKETDEMOD_TEST_SANITIZERS=ON |
||||
- run: cmake --build build-packet-server --target demodpacketsrv packetdemod_sink_test --parallel 2 |
||||
- run: ./build-packet-server/packetdemod_sink_test |
||||
env: |
||||
UBSAN_OPTIONS: halt_on_error=1 |
||||
@ -1,67 +1,67 @@
@@ -1,67 +1,67 @@
|
||||
<?xml version="1.0"?> |
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||
package="org.sdrangel" |
||||
android:installLocation="auto" |
||||
android:versionCode="13" |
||||
android:versionName="7.25.1.1"> |
||||
<uses-permission android:name="android.permission.INTERNET" /> |
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> |
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
||||
<uses-permission android:name="android.permission.CAMERA" /> |
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" /> |
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> |
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> |
||||
<uses-permission android:name="android.permission.WAKE_LOCK" /> |
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> |
||||
|
||||
<supports-screens |
||||
android:anyDensity="true" |
||||
android:largeScreens="true" |
||||
android:normalScreens="true" |
||||
android:smallScreens="true" /> |
||||
<application |
||||
android:name="org.qtproject.qt.android.bindings.QtApplication" |
||||
android:hardwareAccelerated="true" |
||||
android:label="SDRangel" |
||||
android:extractNativeLibs="true" |
||||
android:requestLegacyExternalStorage="true" |
||||
android:allowBackup="true" |
||||
android:fullBackupOnly="false" |
||||
android:icon="@mipmap/ic_launcher"> |
||||
<activity |
||||
android:name="org.sdrangel.SDRangelActivity" |
||||
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" |
||||
android:label="SDRangel" |
||||
android:launchMode="singleTop" |
||||
android:screenOrientation="unspecified" |
||||
android:exported="true"> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN" /> |
||||
<category android:name="android.intent.category.LAUNCHER" /> |
||||
</intent-filter> |
||||
|
||||
<meta-data |
||||
android:name="android.app.lib_name" |
||||
android:value="sdrangel" /> |
||||
|
||||
<meta-data |
||||
android:name="android.app.arguments" |
||||
android:value="" /> |
||||
|
||||
<meta-data |
||||
android:name="android.app.background_running" |
||||
android:value="true" /> |
||||
</activity> |
||||
|
||||
<provider |
||||
android:name="androidx.core.content.FileProvider" |
||||
android:authorities="${applicationId}.qtprovider" |
||||
android:exported="false" |
||||
android:grantUriPermissions="true"> |
||||
<meta-data |
||||
android:name="android.support.FILE_PROVIDER_PATHS" |
||||
android:resource="@xml/qtprovider_paths"/> |
||||
</provider> |
||||
</application> |
||||
</manifest> |
||||
<?xml version="1.0"?> |
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||
package="org.sdrangel" |
||||
android:installLocation="auto" |
||||
android:versionCode="13" |
||||
android:versionName="7.25.1.1"> |
||||
<uses-permission android:name="android.permission.INTERNET" /> |
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> |
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
||||
<uses-permission android:name="android.permission.CAMERA" /> |
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" /> |
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> |
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> |
||||
<uses-permission android:name="android.permission.WAKE_LOCK" /> |
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> |
||||
|
||||
<supports-screens |
||||
android:anyDensity="true" |
||||
android:largeScreens="true" |
||||
android:normalScreens="true" |
||||
android:smallScreens="true" /> |
||||
<application |
||||
android:name="org.qtproject.qt.android.bindings.QtApplication" |
||||
android:hardwareAccelerated="true" |
||||
android:label="SDRangel" |
||||
android:extractNativeLibs="true" |
||||
android:requestLegacyExternalStorage="true" |
||||
android:allowBackup="true" |
||||
android:fullBackupOnly="false" |
||||
android:icon="@mipmap/ic_launcher"> |
||||
<activity |
||||
android:name="org.sdrangel.SDRangelActivity" |
||||
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" |
||||
android:label="SDRangel" |
||||
android:launchMode="singleTop" |
||||
android:screenOrientation="unspecified" |
||||
android:exported="true"> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN" /> |
||||
<category android:name="android.intent.category.LAUNCHER" /> |
||||
</intent-filter> |
||||
|
||||
<meta-data |
||||
android:name="android.app.lib_name" |
||||
android:value="sdrangel" /> |
||||
|
||||
<meta-data |
||||
android:name="android.app.arguments" |
||||
android:value="" /> |
||||
|
||||
<meta-data |
||||
android:name="android.app.background_running" |
||||
android:value="true" /> |
||||
</activity> |
||||
|
||||
<provider |
||||
android:name="androidx.core.content.FileProvider" |
||||
android:authorities="${applicationId}.qtprovider" |
||||
android:exported="false" |
||||
android:grantUriPermissions="true"> |
||||
<meta-data |
||||
android:name="android.support.FILE_PROVIDER_PATHS" |
||||
android:resource="@xml/qtprovider_paths"/> |
||||
</provider> |
||||
</application> |
||||
</manifest> |
||||
|
||||
@ -1,26 +1,26 @@
@@ -1,26 +1,26 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2025 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once |
||||
|
||||
#include "loggerwithfile.h" |
||||
|
||||
void installCrashHandler(qtwebapp::LoggerWithFile *logger); |
||||
|
||||
#ifdef _WIN32 |
||||
void logWindowsStackTrace(); |
||||
#endif |
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2025 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once |
||||
|
||||
#include "loggerwithfile.h" |
||||
|
||||
void installCrashHandler(qtwebapp::LoggerWithFile *logger); |
||||
|
||||
#ifdef _WIN32 |
||||
void logWindowsStackTrace(); |
||||
#endif |
||||
|
||||
@ -0,0 +1,113 @@
@@ -0,0 +1,113 @@
|
||||
if(NOT FDKAAC_FOUND) |
||||
find_package(PkgConfig QUIET) |
||||
if(PkgConfig_FOUND) |
||||
pkg_check_modules(PC_FDKAAC QUIET fdk-aac) |
||||
endif() |
||||
|
||||
find_path( |
||||
FDKAAC_INCLUDE_DIR |
||||
NAMES fdk-aac/aacdecoder_lib.h aacdecoder_lib.h |
||||
HINTS ${FDKAAC_DIR}/include |
||||
${FDK_AAC_DIR}/include |
||||
${PC_FDKAAC_INCLUDE_DIRS} |
||||
PATHS /usr/local/include |
||||
/usr/include |
||||
) |
||||
|
||||
find_library( |
||||
FDKAAC_LIBRARY |
||||
NAMES fdk-aac fdk_aac |
||||
HINTS ${FDKAAC_DIR}/lib |
||||
${FDK_AAC_DIR}/lib |
||||
${PC_FDKAAC_LIBRARY_DIRS} |
||||
PATHS /usr/local/lib |
||||
/usr/lib |
||||
/usr/lib64 |
||||
) |
||||
|
||||
if(FDKAAC_INCLUDE_DIR AND FDKAAC_LIBRARY) |
||||
include(CheckCXXSourceCompiles) |
||||
set(_FDKAAC_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") |
||||
set(_FDKAAC_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") |
||||
set(CMAKE_REQUIRED_INCLUDES "${FDKAAC_INCLUDE_DIR}") |
||||
set(CMAKE_REQUIRED_LIBRARIES "${FDKAAC_LIBRARY}") |
||||
# Recheck when switching packages; a cached header-only success is not |
||||
# evidence that the selected library exports the decoder interface. |
||||
file(SHA256 "${FDKAAC_LIBRARY}" _FDKAAC_LIBRARY_HASH) |
||||
set(_FDKAAC_PACKAGE_KEY "${FDKAAC_INCLUDE_DIR};${FDKAAC_LIBRARY};${_FDKAAC_LIBRARY_HASH};link-v1") |
||||
if(NOT "${FDKAAC_CHECKED_PACKAGE}" STREQUAL "${_FDKAAC_PACKAGE_KEY}") |
||||
unset(FDKAAC_DRM_INTERFACE_AVAILABLE CACHE) |
||||
unset(FDKAAC_RUNTIME_LIBRARY CACHE) |
||||
endif() |
||||
check_cxx_source_compiles(" |
||||
#if __has_include(<fdk-aac/aacdecoder_lib.h>) |
||||
# include <fdk-aac/aacdecoder_lib.h> |
||||
#else |
||||
# include <aacdecoder_lib.h> |
||||
#endif |
||||
#if AACDECODER_LIB_VL0 < 3 |
||||
# error FDK AAC decoder is too old for the validated DRM interface |
||||
#endif |
||||
int main() |
||||
{ |
||||
TRANSPORT_TYPE transport = TT_DRM; |
||||
AUDIO_OBJECT_TYPE objectType = AOT_DRM_USAC; |
||||
HANDLE_AACDECODER decoder = aacDecoder_Open(transport, 2); |
||||
UCHAR *bytes = nullptr; |
||||
UINT size = 0, valid = 0; |
||||
INT_PCM pcm[4096] = {}; |
||||
AAC_DECODER_ERROR status = aacDecoder_ConfigRaw(decoder, &bytes, &size); |
||||
status = aacDecoder_Fill(decoder, &bytes, &size, &valid); |
||||
status = aacDecoder_DecodeFrame(decoder, pcm, 4096, AACDEC_CONCEAL); |
||||
CStreamInfo *info = aacDecoder_GetStreamInfo(decoder); |
||||
aacDecoder_Close(decoder); |
||||
return info && status == AAC_DEC_OK && objectType == AOT_DRM_USAC ? 0 : 1; |
||||
} |
||||
" FDKAAC_DRM_INTERFACE_AVAILABLE) |
||||
set(CMAKE_REQUIRED_INCLUDES "${_FDKAAC_REQUIRED_INCLUDES}") |
||||
set(CMAKE_REQUIRED_LIBRARIES "${_FDKAAC_REQUIRED_LIBRARIES}") |
||||
set(FDKAAC_CHECKED_PACKAGE "${_FDKAAC_PACKAGE_KEY}" CACHE INTERNAL "FDK AAC interface probe package") |
||||
unset(_FDKAAC_REQUIRED_INCLUDES) |
||||
unset(_FDKAAC_REQUIRED_LIBRARIES) |
||||
unset(_FDKAAC_LIBRARY_HASH) |
||||
unset(_FDKAAC_PACKAGE_KEY) |
||||
endif() |
||||
|
||||
if(WIN32) |
||||
get_filename_component(_FDKAAC_LIBRARY_DIR "${FDKAAC_LIBRARY}" DIRECTORY) |
||||
find_file( |
||||
FDKAAC_RUNTIME_LIBRARY |
||||
NAMES fdk-aac.dll libfdk-aac.dll fdk-aac-2.dll libfdk-aac-2.dll |
||||
HINTS ${FDKAAC_DIR}/bin |
||||
${FDK_AAC_DIR}/bin |
||||
${_FDKAAC_LIBRARY_DIR} |
||||
${_FDKAAC_LIBRARY_DIR}/../bin |
||||
${PC_FDKAAC_LIBRARY_DIRS} |
||||
) |
||||
unset(_FDKAAC_LIBRARY_DIR) |
||||
endif() |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args( |
||||
FDKAAC |
||||
DEFAULT_MSG |
||||
FDKAAC_LIBRARY |
||||
FDKAAC_INCLUDE_DIR |
||||
FDKAAC_DRM_INTERFACE_AVAILABLE |
||||
) |
||||
|
||||
mark_as_advanced( |
||||
FDKAAC_LIBRARY |
||||
FDKAAC_INCLUDE_DIR |
||||
FDKAAC_RUNTIME_LIBRARY |
||||
FDKAAC_DRM_INTERFACE_AVAILABLE |
||||
) |
||||
endif() |
||||
|
||||
if(FDKAAC_FOUND) |
||||
set(FDKAAC_INCLUDE_DIRS ${FDKAAC_INCLUDE_DIR}) |
||||
set(FDKAAC_LIBRARIES ${FDKAAC_LIBRARY}) |
||||
# Deliberately not FDK_AAC_FOUND: that spelling decides whether the FFmpeg |
||||
# external project builds its own copy, and FFmpeg finds FDK through |
||||
# pkg-config, which this DRM-only discovery does not guarantee. |
||||
endif() |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
; Offers the Claude Desktop extension, when Claude Desktop is installed. |
||||
; |
||||
; Claude registers no .mcpb file association, and the packaged (MSIX) build has no execution |
||||
; alias, so the only way to hand it a bundle is to run its executable with the bundle as an |
||||
; argument. Both the .exe and the MSIX build write the claude:// protocol handler to HKCU |
||||
; with a real path to that executable, which is where it is found here. |
||||
; |
||||
; Claude shows its own install dialog, with its own warning about what an extension can do, |
||||
; so this only asks whether to open it. |
||||
; |
||||
; Included from CPACK_NSIS_EXTRA_INSTALL_COMMANDS. Kept in a file of its own because CPack |
||||
; writes that variable into CPackConfig.cmake unescaped, so it cannot contain a quote. |
||||
|
||||
IfFileExists "$INSTDIR\@MCPBRIDGE_BUNDLE_NAME@" 0 mcpbDone |
||||
|
||||
ReadRegStr $R0 HKCU "Software\Classes\claude\shell\open\command" "" |
||||
StrCmp $R0 "" mcpbDone |
||||
|
||||
; The value is "<path to the executable>" "%1". Take what the first pair of quotes holds |
||||
StrCpy $R5 $R0 1 ; the opening quote, to compare against and to quote with later |
||||
StrCpy $R1 $R0 "" 1 |
||||
StrCpy $R2 0 |
||||
|
||||
mcpbScan: |
||||
StrCpy $R3 $R1 1 $R2 |
||||
StrCmp $R3 $R5 mcpbFound |
||||
StrCmp $R3 "" mcpbDone ; no closing quote: not a shape we understand, leave it alone |
||||
IntOp $R2 $R2 + 1 |
||||
Goto mcpbScan |
||||
|
||||
mcpbFound: |
||||
StrCpy $R4 $R1 $R2 |
||||
|
||||
; The path carries the version of the Claude that wrote it, so an update that has not been |
||||
; launched since can leave it pointing at a directory that is gone |
||||
IfFileExists "$R4" 0 mcpbDone |
||||
|
||||
MessageBox MB_YESNO|MB_ICONQUESTION "Install the SDRangel extension for Claude Desktop?$\r$\n$\r$\nThis lets Claude control SDRangel. Claude will ask you to confirm." IDNO mcpbDone |
||||
Exec '"$R4" "$INSTDIR\@MCPBRIDGE_BUNDLE_NAME@"' |
||||
|
||||
mcpbDone: |
||||
@ -0,0 +1,115 @@
@@ -0,0 +1,115 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
|
||||
// Some code by AI //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QStringList> |
||||
|
||||
#include "deviceusrpstreamstats.h" |
||||
|
||||
DeviceUSRPStreamStats::DeviceUSRPStreamStats() : |
||||
m_running(false), |
||||
m_started(false), |
||||
m_lastCount(0), |
||||
m_offset(0), |
||||
m_runTimeMs(0) |
||||
{ |
||||
} |
||||
|
||||
void DeviceUSRPStreamStats::update(bool running, quint32 count) |
||||
{ |
||||
if (running && !m_running) |
||||
{ |
||||
// Stream started - reset statistics
|
||||
m_started = true; |
||||
m_lastCount = 0; |
||||
m_offset = 0; |
||||
m_runTimer.start(); |
||||
m_runTimeMs = 0; |
||||
m_lastEventTime = QDateTime(); |
||||
m_history.clear(); |
||||
} |
||||
else if (!running && m_running) |
||||
{ |
||||
// Stream stopped - keep statistics from last run
|
||||
m_runTimeMs = m_runTimer.elapsed(); |
||||
} |
||||
|
||||
m_running = running; |
||||
|
||||
if (!running) { |
||||
return; |
||||
} |
||||
|
||||
if (count < m_lastCount) |
||||
{ |
||||
// Streaming thread was restarted, which resets its count
|
||||
m_offset += m_lastCount; |
||||
|
||||
if (count > 0) { // Events since restart
|
||||
m_lastEventTime = QDateTime::currentDateTime(); |
||||
} |
||||
} |
||||
else if (count > m_lastCount) |
||||
{ |
||||
m_lastEventTime = QDateTime::currentDateTime(); |
||||
} |
||||
|
||||
m_lastCount = count; |
||||
|
||||
// Keep history for last minute, so we can count recent events
|
||||
qint64 now = m_runTimer.elapsed(); |
||||
m_history.push_back({now, getCount()}); |
||||
|
||||
while ((m_history.size() > 1) && (now - m_history.front().first > m_historyMs)) { |
||||
m_history.pop_front(); |
||||
} |
||||
} |
||||
|
||||
QString DeviceUSRPStreamStats::getToolTip(const QString& description, const QString& eventName) const |
||||
{ |
||||
QStringList lines; |
||||
|
||||
lines.append(description); |
||||
|
||||
if (!m_started) { |
||||
return lines.join("\n"); |
||||
} |
||||
|
||||
quint64 count = getCount(); |
||||
qint64 runTimeMs = m_running ? m_runTimer.elapsed() : m_runTimeMs; |
||||
|
||||
lines.append(""); |
||||
lines.append(QString("%1%2: %3").arg(eventName).arg(m_running ? "" : " (last run)").arg(count)); |
||||
|
||||
if (runTimeMs >= 1000) |
||||
{ |
||||
double perMinute = count / (runTimeMs / 60000.0); |
||||
lines.append(QString("Average: %1 per minute").arg(QString::number(perMinute, 'f', 1))); |
||||
} |
||||
|
||||
if (m_running && !m_history.empty()) { |
||||
lines.append(QString("Last minute: %1").arg(count - m_history.front().second)); |
||||
} |
||||
|
||||
if (m_lastEventTime.isValid()) |
||||
{ |
||||
qint64 secsAgo = m_lastEventTime.secsTo(QDateTime::currentDateTime()); |
||||
lines.append(QString("Last: %1 (%2 s ago)").arg(m_lastEventTime.toString("hh:mm:ss")).arg(secsAgo)); |
||||
} |
||||
|
||||
return lines.join("\n"); |
||||
} |
||||
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
|
||||
// Some code by AI //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DEVICES_USRP_DEVICEUSRPSTREAMSTATS_H_ |
||||
#define DEVICES_USRP_DEVICEUSRPSTREAMSTATS_H_ |
||||
|
||||
#include <deque> |
||||
#include <utility> |
||||
|
||||
#include <QString> |
||||
#include <QDateTime> |
||||
#include <QElapsedTimer> |
||||
|
||||
#include "export.h" |
||||
|
||||
/**
|
||||
* Statistics for stream events (E.g. overruns, underruns, timeouts or dropped packets), |
||||
* calculated from the event counts that are periodically reported by the streaming threads. |
||||
* |
||||
* The streaming threads reset their counts whenever they are restarted, which can happen |
||||
* while the stream is running (E.g. when paused while a buddy creates its stream), |
||||
* so counts are accumulated, and only reset when the stream is started. |
||||
*/ |
||||
class DEVICES_API DeviceUSRPStreamStats |
||||
{ |
||||
public: |
||||
DeviceUSRPStreamStats(); |
||||
|
||||
//! Update with latest report. count is the event count reported by the streaming thread.
|
||||
void update(bool running, quint32 count); |
||||
//! Total number of events since the stream was started
|
||||
quint64 getCount() const { return m_offset + m_lastCount; } |
||||
//! Get tooltip, with statistics appended to description. eventName is plural (E.g. "Overruns")
|
||||
QString getToolTip(const QString& description, const QString& eventName) const; |
||||
|
||||
private: |
||||
bool m_running; |
||||
bool m_started; //!< Stream has been started at least once
|
||||
quint32 m_lastCount; //!< Last count reported by streaming thread
|
||||
quint64 m_offset; //!< Accumulated count from before the streaming thread's count was reset
|
||||
QElapsedTimer m_runTimer; //!< Time since stream was started
|
||||
qint64 m_runTimeMs; //!< Run time when stopped
|
||||
QDateTime m_lastEventTime; |
||||
std::deque<std::pair<qint64, quint64>> m_history; //!< (run time ms, total count) for last minute
|
||||
|
||||
static const qint64 m_historyMs = 60000; |
||||
}; |
||||
|
||||
#endif // DEVICES_USRP_DEVICEUSRPSTREAMSTATS_H_
|
||||
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 178 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 437 KiB |
|
After Width: | Height: | Size: 742 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 537 KiB |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
# Mirrors the headers of one directory into another, so that sources including a library by a |
||||
# subdirectory name it does not have in its own tree - <libairspy/airspy.h>, <dsp/dvcontroller.h> - |
||||
# resolve. Only the files directly in SRC are copied and no subdirectory is descended into, so a |
||||
# destination inside SRC does not end up copying itself. |
||||
# |
||||
# Run as: cmake -DSRC=<dir> -DDEST=<dir> -P copy_headers.cmake |
||||
|
||||
file(GLOB headers "${SRC}/*.h" "${SRC}/*.hpp") |
||||
|
||||
file(MAKE_DIRECTORY "${DEST}") |
||||
|
||||
if (headers) |
||||
# file(COPY) skips a file that is already there with the same timestamp, so repeating this on |
||||
# every build costs no rebuilds |
||||
file(COPY ${headers} DESTINATION "${DEST}") |
||||
endif () |
||||
@ -1 +1 @@
@@ -1 +1 @@
|
||||
Subproject commit 72317cca9b2362b8acfd68efcd0d7ad169ce1b7d |
||||
Subproject commit 3c47fdd217d930ac6688b3af66a73752762c3ed2 |
||||
@ -1,50 +1,50 @@
@@ -1,50 +1,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2025 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "bufferlogger.h" |
||||
|
||||
using namespace qtwebapp; |
||||
|
||||
BufferLogger::BufferLogger(int maxSize, QObject *parent) : |
||||
Logger(parent), |
||||
m_maxSize(maxSize) |
||||
{ |
||||
} |
||||
|
||||
BufferLogger::~BufferLogger() |
||||
{ |
||||
} |
||||
|
||||
void BufferLogger::write(const LogMessage* logMessage) |
||||
{ |
||||
QString text = qPrintable(logMessage->toString("{timestamp} {type} {msg}", "yyyy-MM-dd HH:mm:ss.zzz")); |
||||
m_messages.enqueue(text); |
||||
while (m_messages.size() > m_maxSize) { |
||||
m_messages.dequeue(); |
||||
} |
||||
} |
||||
|
||||
QString BufferLogger::getLog() const |
||||
{ |
||||
QString log; |
||||
|
||||
for (const auto& s : m_messages) { |
||||
log.append(s); |
||||
} |
||||
|
||||
return log; |
||||
} |
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2025 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "bufferlogger.h" |
||||
|
||||
using namespace qtwebapp; |
||||
|
||||
BufferLogger::BufferLogger(int maxSize, QObject *parent) : |
||||
Logger(parent), |
||||
m_maxSize(maxSize) |
||||
{ |
||||
} |
||||
|
||||
BufferLogger::~BufferLogger() |
||||
{ |
||||
} |
||||
|
||||
void BufferLogger::write(const LogMessage* logMessage) |
||||
{ |
||||
QString text = qPrintable(logMessage->toString("{timestamp} {type} {msg}", "yyyy-MM-dd HH:mm:ss.zzz")); |
||||
m_messages.enqueue(text); |
||||
while (m_messages.size() > m_maxSize) { |
||||
m_messages.dequeue(); |
||||
} |
||||
} |
||||
|
||||
QString BufferLogger::getLog() const |
||||
{ |
||||
QString log; |
||||
|
||||
for (const auto& s : m_messages) { |
||||
log.append(s); |
||||
} |
||||
|
||||
return log; |
||||
} |
||||
|
||||
@ -1,46 +1,46 @@
@@ -1,46 +1,46 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2025 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once |
||||
|
||||
#include <QQueue> |
||||
|
||||
#include "logger.h" |
||||
#include "export.h" |
||||
|
||||
namespace qtwebapp { |
||||
|
||||
// A ring-buffer like logger for holding m_maxSize recent log messages
|
||||
class LOGGING_API BufferLogger : public Logger { |
||||
Q_OBJECT |
||||
Q_DISABLE_COPY(BufferLogger) |
||||
|
||||
public: |
||||
BufferLogger(int maxSize, QObject *parent = nullptr); |
||||
virtual ~BufferLogger(); |
||||
|
||||
void write(const LogMessage* logMessage) override; |
||||
QString getLog() const; // Get last m_maxSize messages as one big string
|
||||
|
||||
private: |
||||
|
||||
int m_maxSize; // Maximum number of messages to store
|
||||
QQueue<QString> m_messages; // Queue containing last m_maxSize messages
|
||||
|
||||
}; |
||||
|
||||
} |
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2025 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once |
||||
|
||||
#include <QQueue> |
||||
|
||||
#include "logger.h" |
||||
#include "export.h" |
||||
|
||||
namespace qtwebapp { |
||||
|
||||
// A ring-buffer like logger for holding m_maxSize recent log messages
|
||||
class LOGGING_API BufferLogger : public Logger { |
||||
Q_OBJECT |
||||
Q_DISABLE_COPY(BufferLogger) |
||||
|
||||
public: |
||||
BufferLogger(int maxSize, QObject *parent = nullptr); |
||||
virtual ~BufferLogger(); |
||||
|
||||
void write(const LogMessage* logMessage) override; |
||||
QString getLog() const; // Get last m_maxSize messages as one big string
|
||||
|
||||
private: |
||||
|
||||
int m_maxSize; // Maximum number of messages to store
|
||||
QQueue<QString> m_messages; // Queue containing last m_maxSize messages
|
||||
|
||||
}; |
||||
|
||||
} |
||||
|
||||
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
project(modemdrm) |
||||
|
||||
set(modemdrm_SOURCES |
||||
drmacquisition.cpp |
||||
drmaudiodecoder.cpp |
||||
drmaudioframing.cpp |
||||
drmbitutils.cpp |
||||
drmcellmap.cpp |
||||
drmchannelestimator.cpp |
||||
drmconvolutional.cpp |
||||
drmdata.cpp |
||||
drmfac.cpp |
||||
drmfacacquisition.cpp |
||||
drmjournaline.cpp |
||||
drminterleaver.cpp |
||||
drmmsc.cpp |
||||
drmofdm.cpp |
||||
drmparameters.cpp |
||||
drmreceiver.cpp |
||||
drmresampler.cpp |
||||
drmsdc.cpp |
||||
drmsyncstatemachine.cpp |
||||
) |
||||
|
||||
set(modemdrm_HEADERS |
||||
drmacquisition.h |
||||
drmaudiodecoder.h |
||||
drmaudioframing.h |
||||
drmbitutils.h |
||||
drmcellmap.h |
||||
drmchannelestimator.h |
||||
drmconvolutional.h |
||||
drmdata.h |
||||
drmfac.h |
||||
drmfacacquisition.h |
||||
drmjournaline.h |
||||
drminterleaver.h |
||||
drmmsc.h |
||||
drmofdm.h |
||||
drmparameters.h |
||||
drmreceiver.h |
||||
drmresampler.h |
||||
drmsdc.h |
||||
drmsyncstatemachine.h |
||||
) |
||||
|
||||
add_library(modemdrm ${modemdrm_SOURCES}) |
||||
|
||||
target_include_directories(modemdrm |
||||
PUBLIC |
||||
${CMAKE_SOURCE_DIR} |
||||
${CMAKE_SOURCE_DIR}/exports |
||||
) |
||||
|
||||
# DRM AAC/xHE-AAC audio uses the FDK AAC decoder |
||||
if(FDKAAC_FOUND) |
||||
message(STATUS "modemdrm: DRM AAC/xHE-AAC audio via FDK AAC") |
||||
target_compile_definitions(modemdrm PRIVATE MODEMDRM_HAS_FDK_AAC=1) |
||||
target_include_directories(modemdrm PRIVATE ${FDKAAC_INCLUDE_DIR}) |
||||
target_link_libraries(modemdrm PRIVATE ${FDKAAC_LIBRARY}) |
||||
if(DEFINED FDKAAC_DEPENDS) |
||||
add_dependencies(modemdrm ${FDKAAC_DEPENDS}) |
||||
endif() |
||||
# The external FDK is private to modemdrm. Do not re-export its aacDecoder_* |
||||
# symbols from a shared modemdrm, so they cannot interpose on (or be |
||||
# interposed by) the libfdk-aac that FFmpeg loads in the same process. |
||||
if(FDKAAC_EXTERNAL AND BUILD_SHARED_LIBS AND UNIX AND NOT APPLE) |
||||
target_link_options(modemdrm PRIVATE "LINKER:--exclude-libs,libfdk-aac.a") |
||||
endif() |
||||
endif() |
||||
|
||||
# DRM AAC can be decoded by FAAD2 built for DRM (faad_drm), but it does not support xHE-AAC. |
||||
if(FAAD_DRM_LIBRARY AND NOT FDKAAC_FOUND) |
||||
message(STATUS "modemdrm: DRM AAC audio via FAAD2 - xHE-AAC not supported") |
||||
target_compile_definitions(modemdrm PRIVATE MODEMDRM_HAS_FAAD2=1) |
||||
target_include_directories(modemdrm PRIVATE ${FAAD_INCLUDE_DIR}) |
||||
target_link_libraries(modemdrm PRIVATE ${FAAD_DRM_LIBRARY}) |
||||
if(DEFINED FAAD_DEPENDS) |
||||
add_dependencies(modemdrm ${FAAD_DEPENDS}) |
||||
endif() |
||||
endif() |
||||
|
||||
# Without either library DRM still demodulates and lists services, and reports the codec as unavailable. |
||||
if(NOT FDKAAC_FOUND AND NOT FAAD_DRM_LIBRARY) |
||||
message(STATUS "modemdrm: no DRM audio codec") |
||||
endif() |
||||
|
||||
install(TARGETS modemdrm DESTINATION ${INSTALL_LIB_DIR}) |
||||
|
||||
if(FDKAAC_FOUND AND NOT FDKAAC_EXTERNAL AND WIN32 AND FDKAAC_RUNTIME_LIBRARY) |
||||
# Shipping a prebuilt library requires shipping its licence (the external |
||||
# build installs its NOTICE itself). |
||||
get_filename_component(_fdk_library_dir "${FDKAAC_LIBRARY}" DIRECTORY) |
||||
find_file(FDKAAC_NOTICE NAMES NOTICE NOTICE.txt |
||||
HINTS ${FDKAAC_DIR} ${FDK_AAC_DIR} "${_fdk_library_dir}/.." "${FDKAAC_INCLUDE_DIR}/.." |
||||
PATH_SUFFIXES . share/doc/fdk-aac share/licenses/fdk-aac) |
||||
unset(_fdk_library_dir) |
||||
if(NOT FDKAAC_NOTICE) |
||||
message(FATAL_ERROR "Installing ${FDKAAC_RUNTIME_LIBRARY} requires its licence: set FDKAAC_NOTICE to the FDK AAC NOTICE file") |
||||
endif() |
||||
install(FILES "${FDKAAC_RUNTIME_LIBRARY}" DESTINATION ${INSTALL_BIN_DIR}) |
||||
install(FILES "${FDKAAC_NOTICE}" DESTINATION "${INSTALL_DOC_DIR}/fdk-aac" RENAME NOTICE) |
||||
endif() |
||||
@ -0,0 +1,333 @@
@@ -0,0 +1,333 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
|
||||
// Some code by AI //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "drmacquisition.h" |
||||
#include "drmofdm.h" |
||||
|
||||
#include <algorithm> |
||||
#include <cmath> |
||||
#include <limits> |
||||
|
||||
namespace modemdrm |
||||
{ |
||||
|
||||
namespace |
||||
{ |
||||
|
||||
constexpr double Pi = 3.14159265358979323846; |
||||
|
||||
} // namespace
|
||||
|
||||
AcquisitionCandidate Acquisition::evaluateMode( |
||||
const std::complex<float>* samples, |
||||
std::size_t sampleCount, |
||||
int sampleRate, |
||||
Mode mode, |
||||
bool alignFirstPath |
||||
) |
||||
{ |
||||
AcquisitionCandidate candidate; |
||||
candidate.mode = mode; |
||||
|
||||
if (samples == nullptr || sampleRate <= 0) { |
||||
return candidate; |
||||
} |
||||
|
||||
const ModeParameters& parameters = Parameters::forMode(mode); |
||||
const int useful = parameters.usefulSamples(sampleRate); |
||||
const int guard = parameters.guardSamples(sampleRate); |
||||
const int symbol = parameters.symbolSamples(sampleRate); |
||||
|
||||
candidate.usefulSamples = useful; |
||||
candidate.guardSamples = guard; |
||||
candidate.symbolSamples = symbol; |
||||
|
||||
if (useful <= 0 || guard <= 0 || symbol <= 0 || sampleCount < static_cast<std::size_t>(useful + 4 * symbol)) { |
||||
return candidate; |
||||
} |
||||
|
||||
const std::size_t pairCount = sampleCount - static_cast<std::size_t>(useful); |
||||
std::vector<std::complex<double>> phaseCorrelation(symbol, {0.0, 0.0}); |
||||
std::vector<double> phaseEnergy(symbol, 0.0); |
||||
std::vector<int> phaseCount(symbol, 0); |
||||
|
||||
// A DC component (a device's DC spur, which in A-D falls on the unused
|
||||
// carrier 0 when the channel offset is zero) correlates at phase zero at every lag and
|
||||
// would pull the fractional frequency estimate towards 0 Hz: remove the
|
||||
// block mean first.
|
||||
std::complex<double> sum(0.0, 0.0); |
||||
for (std::size_t i = 0; i < sampleCount; ++i) { |
||||
sum += static_cast<std::complex<double>>(samples[i]); |
||||
} |
||||
|
||||
const std::complex<float> mean = static_cast<std::complex<float>>(sum / static_cast<double>(sampleCount)); |
||||
int phase = 0; |
||||
for (std::size_t i = 0; i < pairCount; ++i) |
||||
{ |
||||
const std::complex<float> first = samples[i] - mean; |
||||
const std::complex<float> second = samples[i + useful] - mean; |
||||
phaseCorrelation[phase] += static_cast<std::complex<double>>(first * std::conj(second)); |
||||
phaseEnergy[phase] += 0.5 * (std::norm(first) + std::norm(second)); |
||||
phaseCount[phase]++; |
||||
if (++phase == symbol) { |
||||
phase = 0; |
||||
} |
||||
} |
||||
|
||||
std::complex<double> windowCorrelation(0.0, 0.0); |
||||
double windowEnergy = 0.0; |
||||
int windowCount = 0; |
||||
|
||||
for (int i = 0; i < guard; ++i) |
||||
{ |
||||
windowCorrelation += phaseCorrelation[i]; |
||||
windowEnergy += phaseEnergy[i]; |
||||
windowCount += phaseCount[i]; |
||||
} |
||||
|
||||
double bestScore = -1.0; |
||||
std::complex<double> bestCorrelation(0.0, 0.0); |
||||
int bestStart = 0; |
||||
int bestCount = 0; |
||||
std::vector<double> scores(static_cast<std::size_t>(symbol), 0.0); |
||||
|
||||
for (int start = 0; start < symbol; ++start) |
||||
{ |
||||
const double score = windowEnergy > std::numeric_limits<double>::epsilon() |
||||
? std::abs(windowCorrelation) / windowEnergy |
||||
: 0.0; |
||||
|
||||
scores[static_cast<std::size_t>(start)] = score; |
||||
if (score > bestScore) |
||||
{ |
||||
bestScore = score; |
||||
bestCorrelation = windowCorrelation; |
||||
bestStart = start; |
||||
bestCount = windowCount; |
||||
} |
||||
|
||||
const int leaving = start; |
||||
const int entering = (start + guard) % symbol; |
||||
windowCorrelation += phaseCorrelation[entering] - phaseCorrelation[leaving]; |
||||
windowEnergy += phaseEnergy[entering] - phaseEnergy[leaving]; |
||||
windowCount += phaseCount[entering] - phaseCount[leaving]; |
||||
} |
||||
|
||||
// Each path adds its power to the cyclic-prefix correlation over its own
|
||||
// guard-length span, so the guard window's maximum falls wherever the
|
||||
// stronger paths put it. Align to the first significant path instead, so
|
||||
// that the FFT window (at the end of the guard) holds every echo the guard
|
||||
// can; aligning to a later path lets the first path's next symbol into
|
||||
// the window. Walk back from the maximum along the (lightly smoothed)
|
||||
// per-offset profile while it stays above the noise floor plus a fraction
|
||||
// of its peak: a first path too weak to pass the threshold contributes
|
||||
// little interference. The centred smoothing spreads a lone path's
|
||||
// leading edge earlier, so its start comes out up to about half the box
|
||||
// early (inside the guard, and only until tracking takes over); undoing
|
||||
// that overshoots behind a weaker first path, where the profile rises
|
||||
// gradually.
|
||||
if (alignFirstPath) |
||||
{ |
||||
std::vector<double> profile(static_cast<std::size_t>(symbol), 0.0); |
||||
for (int phase = 0; phase < symbol; ++phase) |
||||
{ |
||||
const double energy = phaseEnergy[static_cast<std::size_t>(phase)]; |
||||
profile[static_cast<std::size_t>(phase)] = energy > std::numeric_limits<double>::epsilon() |
||||
? std::abs(phaseCorrelation[static_cast<std::size_t>(phase)]) / energy : 0.0; |
||||
} |
||||
|
||||
const int half = std::max(2, guard / 32); |
||||
std::vector<double> smoothed(static_cast<std::size_t>(symbol), 0.0); |
||||
for (int phase = 0; phase < symbol; ++phase) |
||||
{ |
||||
double sum = 0.0; |
||||
for (int k = -half; k < half; ++k) { |
||||
sum += profile[static_cast<std::size_t>((phase + k + symbol) % symbol)]; |
||||
} |
||||
|
||||
smoothed[static_cast<std::size_t>(phase)] = sum / (2 * half); |
||||
} |
||||
|
||||
// Noise floor from a low percentile: with a long guard and long echoes
|
||||
// most offsets carry correlation, so the median would be signal.
|
||||
std::vector<double> sorted = smoothed; |
||||
const auto floorIndex = static_cast<std::size_t>(symbol / 10); |
||||
std::nth_element(sorted.begin(), sorted.begin() + static_cast<std::ptrdiff_t>(floorIndex), sorted.end()); |
||||
const double noise = sorted[floorIndex]; |
||||
double peak = 0.0; |
||||
for (int k = 0; k < guard; ++k) { |
||||
peak = std::max(peak, smoothed[static_cast<std::size_t>((bestStart + k) % symbol)]); |
||||
} |
||||
|
||||
// Above the noise's spread as well as its floor: the averaged noise
|
||||
// magnitude stays within about twice its 10th percentile.
|
||||
const double threshold = std::max(NoiseMargin * noise, noise + FirstPathFraction * (peak - noise)); |
||||
// Tolerate brief dips: stop only after a run below the threshold.
|
||||
const int allowedGap = std::max(2, guard / 16); |
||||
int earliestStart = bestStart; |
||||
int gap = 0; |
||||
for (int step = 1; step < guard && gap < allowedGap; ++step) |
||||
{ |
||||
const int start = (bestStart - step + symbol) % symbol; |
||||
if (smoothed[static_cast<std::size_t>(start)] >= threshold) |
||||
{ |
||||
earliestStart = start; |
||||
gap = 0; |
||||
} |
||||
else |
||||
{ |
||||
++gap; |
||||
} |
||||
} |
||||
|
||||
// The FFT window starts a backoff before the end of the guard. The
|
||||
// profile there is the power of the paths whose cyclic prefix covers
|
||||
// that start, i.e. that reach the window free of interference. When
|
||||
// the echoes span more than the guard allows, timing on the first
|
||||
// path can push a stronger later path out: move later until the
|
||||
// window start holds most of the best achievable power.
|
||||
const int windowOffset = guard - OFDMDemodulator::backoffSamplesFor(guard); |
||||
double best = 0.0; |
||||
for (double value : smoothed) { |
||||
best = std::max(best, value); |
||||
} |
||||
|
||||
for (int step = 0; step < guard; ++step) |
||||
{ |
||||
const int start = (earliestStart + step) % symbol; |
||||
if (smoothed[static_cast<std::size_t>((start + windowOffset) % symbol)] >= WindowPowerFraction * best) |
||||
{ |
||||
earliestStart = start; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
bestStart = earliestStart; |
||||
} |
||||
else |
||||
{ |
||||
// Where the FFT window may start: the span around the per-offset
|
||||
// profile's maximum within WindowPowerFraction of it, where every
|
||||
// significant path's cyclic prefix covers the window start.
|
||||
const int half = std::max(2, guard / 32); |
||||
std::vector<double> smoothed(static_cast<std::size_t>(symbol), 0.0); |
||||
for (int phase = 0; phase < symbol; ++phase) |
||||
{ |
||||
double sum = 0.0; |
||||
for (int k = -half; k < half; ++k) |
||||
{ |
||||
const auto index = static_cast<std::size_t>((phase + k + symbol) % symbol); |
||||
const double energy = phaseEnergy[index]; |
||||
if (energy > std::numeric_limits<double>::epsilon()) { |
||||
sum += std::abs(phaseCorrelation[index]) / energy; |
||||
} |
||||
} |
||||
|
||||
smoothed[static_cast<std::size_t>(phase)] = sum / (2 * half); |
||||
} |
||||
|
||||
int peakPhase = 0; |
||||
for (int phase = 1; phase < symbol; ++phase) |
||||
{ |
||||
if (smoothed[static_cast<std::size_t>(phase)] > smoothed[static_cast<std::size_t>(peakPhase)]) { |
||||
peakPhase = phase; |
||||
} |
||||
} |
||||
|
||||
const double limit = WindowPowerFraction * smoothed[static_cast<std::size_t>(peakPhase)]; |
||||
int before = 0; |
||||
while (before < guard && smoothed[static_cast<std::size_t>((peakPhase - before - 1 + symbol) % symbol)] >= limit) { |
||||
++before; |
||||
} |
||||
|
||||
int after = 0; |
||||
while (after < guard && smoothed[static_cast<std::size_t>((peakPhase + after + 1) % symbol)] >= limit) { |
||||
++after; |
||||
} |
||||
|
||||
candidate.windowEndOffsetSamples = (peakPhase + after) % symbol; |
||||
candidate.windowSpanSamples = before + after + 1; |
||||
} |
||||
|
||||
candidate.cyclicPrefixCorrelation = static_cast<float>( |
||||
std::max(0.0, std::min(1.0, bestScore)) |
||||
); |
||||
{ |
||||
// A low percentile: strong echoes raise the correlation over much of
|
||||
// the symbol, so the median can lie within the cyclic prefix's span.
|
||||
const auto floor = scores.begin() + static_cast<std::ptrdiff_t>(scores.size() / 10U); |
||||
std::nth_element(scores.begin(), floor, scores.end()); |
||||
candidate.cyclicPrefixFloor = static_cast<float>(std::max(0.0, *floor)); |
||||
} |
||||
|
||||
candidate.valid = bestCount >= 4 * guard |
||||
&& candidate.cyclicPrefixCorrelation >= MinimumCyclicPrefixCorrelation |
||||
&& candidate.cyclicPrefixCorrelation - candidate.cyclicPrefixFloor |
||||
>= MinimumCyclicPrefixExcess * (1.0f - candidate.cyclicPrefixFloor); |
||||
candidate.symbolStartOffsetSamples = bestStart; |
||||
candidate.symbolsObserved = guard > 0 ? bestCount / guard : 0; |
||||
candidate.fractionalCarrierOffsetHz = -std::arg(bestCorrelation) / (2.0 * Pi * parameters.usefulDurationSeconds()); |
||||
|
||||
return candidate; |
||||
} |
||||
|
||||
std::vector<int> Acquisition::integerCarrierHypotheses( |
||||
Mode mode, |
||||
double fractionalCarrierOffsetHz, |
||||
int configuredSearchRangeHz |
||||
) |
||||
{ |
||||
const int range = Parameters::effectiveSearchRangeHz(mode, configuredSearchRangeHz); |
||||
|
||||
if (range < 0) { |
||||
return {}; |
||||
} |
||||
|
||||
const double spacing = Parameters::forMode(mode).carrierSpacingHz(); |
||||
// Floating-point IQ rotation/CP estimation can put an exact endpoint a few
|
||||
// microhertz outside the inclusive bound. Keep a 10-millihertz numerical
|
||||
// allowance so the endpoint's carrier hypothesis is still examined.
|
||||
constexpr double EndpointRoundingHz = 0.01; |
||||
const int minimum = static_cast<int>(std::ceil((-range - EndpointRoundingHz - fractionalCarrierOffsetHz) / spacing)); |
||||
const int maximum = static_cast<int>(std::floor((range + EndpointRoundingHz - fractionalCarrierOffsetHz) / spacing)); |
||||
std::vector<int> hypotheses; |
||||
|
||||
if (minimum > maximum) { |
||||
return hypotheses; |
||||
} |
||||
|
||||
hypotheses.reserve(static_cast<std::size_t>(maximum - minimum + 1)); |
||||
const int nearest = std::max(minimum, std::min(maximum, |
||||
static_cast<int>(std::llround(-fractionalCarrierOffsetHz / spacing)))); |
||||
hypotheses.push_back(nearest); |
||||
|
||||
for (int distance = 1; nearest - distance >= minimum || nearest + distance <= maximum; ++distance) |
||||
{ |
||||
if (nearest - distance >= minimum) { |
||||
hypotheses.push_back(nearest - distance); |
||||
} |
||||
|
||||
if (nearest + distance <= maximum) { |
||||
hypotheses.push_back(nearest + distance); |
||||
} |
||||
} |
||||
|
||||
return hypotheses; |
||||
} |
||||
|
||||
} // namespace modemdrm
|
||||
@ -0,0 +1,98 @@
@@ -0,0 +1,98 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
|
||||
// Some code by AI //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MODEMDRM_DRMACQUISITION_H_ |
||||
#define MODEMDRM_DRMACQUISITION_H_ |
||||
|
||||
#include <complex> |
||||
#include <cstddef> |
||||
#include <vector> |
||||
|
||||
#include "drmparameters.h" |
||||
|
||||
namespace modemdrm |
||||
{ |
||||
|
||||
struct MODEMDRM_API AcquisitionCandidate |
||||
{ |
||||
Mode mode = Mode::A; |
||||
bool valid = false; |
||||
float cyclicPrefixCorrelation = 0.0f; |
||||
// 10th percentile of the guard-window correlation over symbol offsets: the level
|
||||
// noise or interference correlated at the useful-period lag gives.
|
||||
float cyclicPrefixFloor = 0.0f; |
||||
int symbolStartOffsetSamples = 0; |
||||
// Tracking only (alignFirstPath false): the span of FFT-window starts that
|
||||
// hold nearly all the paths' power, as its last offset in the symbol and
|
||||
// its width; width 0 when not measured.
|
||||
int windowEndOffsetSamples = 0; |
||||
int windowSpanSamples = 0; |
||||
double fractionalCarrierOffsetHz = 0.0; |
||||
int usefulSamples = 0; |
||||
int guardSamples = 0; |
||||
int symbolSamples = 0; |
||||
int symbolsObserved = 0; |
||||
}; |
||||
|
||||
class MODEMDRM_API Acquisition |
||||
{ |
||||
public: |
||||
// Coarse cyclic-prefix gate used only to reject implausible mode/timing
|
||||
// candidates. Repeated CRC-valid FAC blocks are still required for lock.
|
||||
static constexpr float MinimumCyclicPrefixCorrelation = 0.10f; |
||||
// A cyclic prefix concentrates its correlation in one guard-length span of
|
||||
// the symbol; noise correlates about equally at every offset, as does
|
||||
// interference correlated at the useful-period lag (a carrier, say), which
|
||||
// raises the floor. The best guard window must exceed the floor (10th
|
||||
// percentile over offsets) by this share of the headroom above it: noise
|
||||
// with interference reached 0.09 and the corpus is at 0.83 or more; 0.15
|
||||
// is about -7 dB SNR, below where FAC decodes. Without it every noisy
|
||||
// capture window that passes the correlation gate costs a full FAC search.
|
||||
static constexpr float MinimumCyclicPrefixExcess = 0.15f; |
||||
// Fraction of the way from the noise floor to the peak of the cyclic-prefix
|
||||
// correlation profile above which a path counts for timing (see
|
||||
// evaluateMode).
|
||||
static constexpr double FirstPathFraction = 0.05; |
||||
// Multiple of the profile's noise floor (10th percentile) a path must exceed.
|
||||
static constexpr double NoiseMargin = 2.2; |
||||
// Share of the best achievable path power the FFT window start must hold.
|
||||
static constexpr double WindowPowerFraction = 0.9; |
||||
|
||||
// Timing is the start of the guard window of greatest cyclic-prefix
|
||||
// correlation, moved to the first significant path when alignFirstPath.
|
||||
static AcquisitionCandidate evaluateMode( |
||||
const std::complex<float>* samples, |
||||
std::size_t sampleCount, |
||||
int sampleRate, |
||||
Mode mode, |
||||
bool alignFirstPath = true |
||||
); |
||||
|
||||
// Produces carrier indices whose absolute offset from fR is within the
|
||||
// configured symmetric range. Ordering starts nearest the fractional
|
||||
// estimate so a receiver can validate cheap hypotheses first.
|
||||
static std::vector<int> integerCarrierHypotheses( |
||||
Mode mode, |
||||
double fractionalCarrierOffsetHz, |
||||
int configuredSearchRangeHz |
||||
); |
||||
}; |
||||
|
||||
} // namespace modemdrm
|
||||
|
||||
#endif // MODEMDRM_DRMACQUISITION_H_
|
||||