Skip to content

Commit

Permalink
workaround broken spirv tools, example API wget call.
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed Oct 19, 2023
1 parent 92138e5 commit c020c05
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 32 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ gamutRF also supports the KrakenSDR (which presents as five librtlsdr radios). Y

The orchestrator has a web interface on port 80. You can use this to command a worker to start an I/Q sample recording or start a RSSI stream.

You can also call the worker API directly (for example, to use a stand-alone worker to make a recording or stream RSSI).

For example, make a recording with a sample rate of 20.48e6, for 2 seconds (409600000 samples worth), at 100MHz:

```
$ wget -nv -O- localhost:8000/v1/record/100000000/409600000/20480000
```

If the worker is started with `--rssi`, that same ```record``` call will cause the worker to publish RSSI values instead of recording (the duration argument must be present, but is not used).

## Working with worker I/Q recordings

Workers make recordings that are compressed with zstandard, and are typically in complex number, int16 format, and include the center frequency and sample rate that the recording was made with. gamutRF tools can generally work with such files directly, but other tools require the recordings to be converted (see below).
Expand Down
5 changes: 3 additions & 2 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ 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.7
RUN git clone https://github.com/iqtlabs/uhd_sample_recorder -b v1.0.8
WORKDIR /root/uhd_sample_recorder
RUN ./bin/install-deps.sh && rm -rf SPIRV-Tools VkFFT
RUN ./bin/install-deps.sh && rm -rf VkFFT
COPY --from=iqtlabs/gamutrf-vkfft:latest /root /root/uhd_sample_recorder
WORKDIR /root/uhd_sample_recorder/build
RUN CMAKE_BUILD_TYPE=Release cmake ../lib && make -j $(nproc) && cp uhd_sample_recorder /usr/local/bin
Expand Down Expand Up @@ -88,6 +88,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
python3-numpy
WORKDIR /root
RUN git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.44
RUN sed -i /SPIRV-Tools/d gr-iqtlabs/lib/CMakeLists.txt
COPY --from=iqtlabs/gamutrf-vkfft:latest /root /root/gr-iqtlabs
WORKDIR /root/gr-iqtlabs/build
COPY --from=sigmf-builder /usr/local /usr/local
Expand Down
10 changes: 2 additions & 8 deletions docker/Dockerfile.vkfft
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
python3-dev
WORKDIR /root
RUN git clone https://github.com/DTolm/VkFFT -b v1.3.1
RUN git clone https://github.com/KhronosGroup/SPIRV-Tools -b v2023.2
WORKDIR /root/SPIRV-Tools/external
RUN git clone https://github.com/KhronosGroup/SPIRV-Headers -b sdk-1.3.246.1 spirv-headers
WORKDIR /root/SPIRV-Tools/build
RUN CMAKE_BUILD_TYPE=Release cmake .. && make -j "$(nproc)" && make install
RUN sed -i -E 's/GIT_TAG\s+"origin.main"/GIT_TAG "13.0.0"/g' VkFFT/CMakeLists.txt
WORKDIR /root/VkFFT/build
RUN CMAKE_BUILD_TYPE=Release cmake -DALLOW_EXTERNAL_SPIRV_TOOLS=ON .. && make -j "$(nproc)"
RUN CMAKE_BUILD_TYPE=Release cmake .. && make -j "$(nproc)"

FROM ubuntu:22.04
# TODO: ideally, should be packaged such that cmake can find it.
COPY --from=vkfft-builder /root/SPIRV-Tools/build/source/opt/libSPIRV-Tools-opt.a /root/SPIRV-Tools/build/source/opt/libSPIRV-Tools-opt.a
COPY --from=vkfft-builder /root/SPIRV-Tools/build/source/libSPIRV-Tools.a /root/SPIRV-Tools/build/source/libSPIRV-Tools.a
COPY --from=vkfft-builder /root/VkFFT /root/VkFFT
45 changes: 24 additions & 21 deletions gamutrf/sdr_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,28 +188,31 @@ def run_recording(
)

if sigmf_:
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 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")
else:
logging.error("{sample_file} missing, cannot write sigmf file")

Check warning on line 213 in gamutrf/sdr_recorder.py

View check run for this annotation

Codecov / codecov/patch

gamutrf/sdr_recorder.py#L213

Added line #L213 was not covered by tests
except subprocess.CalledProcessError as err:
logging.debug("record failed: %s", err)
logging.error("record failed: %s", err)

Check warning on line 215 in gamutrf/sdr_recorder.py

View check run for this annotation

Codecov / codecov/patch

gamutrf/sdr_recorder.py#L215

Added line #L215 was not covered by tests
logging.info("record status: %d", record_status)
return (record_status, sample_file)

Expand Down
2 changes: 1 addition & 1 deletion worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
- 'WORKER_NAME=${WORKER_NAME}'
- 'ORCHESTRATOR=${ORCHESTRATOR}'
- 'ANTENNA=${ANTENNA}'
- 'NFFT=2048'
- 'NFFT=256'
command:
- nice
- '-n'
Expand Down

0 comments on commit c020c05

Please sign in to comment.