From dfbb1c500227ae9c23c94b664de33e15cd1c253c Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Thu, 4 Apr 2024 03:53:33 +0000 Subject: [PATCH] uhd sample recorder can write its own sigmf file now, so only write a meta if the SDR-dependant recorder tool doesn't provide one. --- docker/Dockerfile.uhd-sr | 2 +- gamutrf/sdr_recorder.py | 42 +++++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/docker/Dockerfile.uhd-sr b/docker/Dockerfile.uhd-sr index b5e700b0..7bba672c 100644 --- a/docker/Dockerfile.uhd-sr +++ b/docker/Dockerfile.uhd-sr @@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libvulkan-dev \ sudo WORKDIR /root -RUN git clone https://github.com/iqtlabs/uhd_sample_recorder -b v1.0.9 +RUN git clone https://github.com/iqtlabs/uhd_sample_recorder -b v1.0.11 WORKDIR /root/uhd_sample_recorder RUN ./bin/install-deps.sh && rm -rf VkFFT COPY --from=iqtlabs/gamutrf-vkfft:latest /root /root/uhd_sample_recorder diff --git a/gamutrf/sdr_recorder.py b/gamutrf/sdr_recorder.py index 7fde14b6..a66f73a6 100644 --- a/gamutrf/sdr_recorder.py +++ b/gamutrf/sdr_recorder.py @@ -188,27 +188,29 @@ def run_recording( ) if sigmf_: + sigmf_file = sample_file + ".sigmf-meta" if os.path.exists(sample_file): - meta = sigmf.SigMFFile( - skip_checksum=True, # expensive for large files - data_file=sample_file, - global_info={ - sigmf.SigMFFile.DATATYPE_KEY: "_".join( - ("c" + SAMPLE_TYPE, endianstr()) - ), - sigmf.SigMFFile.SAMPLE_RATE_KEY: sample_rate, - sigmf.SigMFFile.VERSION_KEY: sigmf.__version__, - }, - ) - # TODO: add capture_details, source_file and gain when supported. - meta.add_capture( - 0, - metadata={ - sigmf.SigMFFile.FREQUENCY_KEY: center_freq, - sigmf.SigMFFile.DATETIME_KEY: meta_time, - }, - ) - meta.tofile(sample_file + ".sigmf-meta") + if not os.path.exists(sigmf_file): + meta = sigmf.SigMFFile( + skip_checksum=True, # expensive for large files + data_file=sample_file, + global_info={ + sigmf.SigMFFile.DATATYPE_KEY: "_".join( + ("c" + SAMPLE_TYPE, endianstr()) + ), + sigmf.SigMFFile.SAMPLE_RATE_KEY: sample_rate, + sigmf.SigMFFile.VERSION_KEY: sigmf.__version__, + }, + ) + # TODO: add capture_details, source_file and gain when supported. + meta.add_capture( + 0, + metadata={ + sigmf.SigMFFile.FREQUENCY_KEY: center_freq, + sigmf.SigMFFile.DATETIME_KEY: meta_time, + }, + ) + meta.tofile(sigmf_file) else: logging.error("{sample_file} missing, cannot write sigmf file") except subprocess.CalledProcessError as err: