Skip to content

Commit

Permalink
Implement stare mode, when --freq-end is 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed Nov 28, 2023
1 parent 5aeccf2 commit 084b181
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libvulkan-dev \
python3-numpy
WORKDIR /root
RUN git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.52
RUN git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.53
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
79 changes: 79 additions & 0 deletions docker/Dockerfile.base.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
FROM ubuntu:22.04 as sigmf-builder
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends build-essential ca-certificates cmake git
WORKDIR /root
RUN git clone https://github.com/google/flatbuffers -b v23.5.26
RUN git clone https://github.com/nlohmann/json -b v3.11.2
RUN git clone https://github.com/deepsig/libsigmf -b v1.0.2
WORKDIR /root/flatbuffers/build
RUN cmake .. && make -j "$(nproc)" && make install
WORKDIR /root/json/build
RUN cmake .. && make -j "$(nproc)" && make install
WORKDIR /root/libsigmf/build
RUN cmake -DUSE_SYSTEM_JSON=ON -DUSE_SYSTEM_FLATBUFFERS=ON .. && make -j "$(nproc)" && make install

FROM ubuntu:22.04 as uhd_sample_recorder-builder
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
cmake \
git \
libboost-all-dev \
libuhd-dev \
libvulkan-dev \
sudo
WORKDIR /root
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 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

FROM ubuntu:22.04 as gr-iqtlabs-builder
COPY --from=iqtlabs/gnuradio:3.10.8 /usr/local /usr/local
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
cmake \
git \
libboost-all-dev \
libgmp-dev \
libopencv-dev \
libspdlog-dev \
libuhd-dev \
libvulkan-dev \
python3-numpy
WORKDIR /root
RUN git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.52
COPY --from=iqtlabs/gamutrf-vkfft:latest /root /root/gr-iqtlabs
WORKDIR /root/gr-iqtlabs/build
COPY --from=sigmf-builder /usr/local /usr/local
RUN cmake .. && make -j "$(nproc)" && make install

FROM ubuntu:22.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
libboost-filesystem1.74.0 \
libboost-iostreams1.74.0 \
libboost-program-options1.74.0 \
libboost-thread1.74.0 \
libopencv-core4.5d \
libopencv-imgcodecs4.5d \
libopencv-imgproc4.5d \
librtlsdr0 \
libspdlog1 \
libuhd4.1.0 \
libunwind8 \
libvulkan1 \
python3 \
python3-numpy \
&& apt-get -y -q clean && rm -rf /var/lib/apt/lists/*
COPY --from=iqtlabs/gnuradio:3.10.8 /usr/local /usr/local
COPY --from=iqtlabs/gamutrf-driver /usr/local /usr/local
COPY --from=gr-iqtlabs-builder /usr/local /usr/local
COPY --from=uhd_sample_recorder-builder /usr/local /usr/local
RUN ldconfig -v
RUN python3 -c "from gnuradio import soapy, iqtlabs ; from gnuradio.iqtlabs import vkfft"
4 changes: 2 additions & 2 deletions docs/4-OPERATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ While there are other options, these options primarily influence gamutRF's scann

| Option | Description |
| -- | -- |
| --freq-start and --freq-end | Start and end of frequency range to scan in Hz |
| --freq-start and --freq-end | Start and end of frequency range to scan in Hz (if --freq-end=0, will run in "stare" mode, static scanning from --freq-start to --freq_start + (--tuneoverlap * --samp_rate))|
| --tuning_ranges | Overrides --freq-start and --freq-end if present. A comma separated list of ranges in Hz to scan, for example ```2.2e9-2.6e9,5.1e9-5.9e9``` |
| --igain | SDR input gain in dB |
| --samp-rate | Number of samples/sec |
Expand Down Expand Up @@ -161,4 +161,4 @@ To view other options.
gamutRF supports two separate APIs - for receiving scanner updates, and making scanner configuration changes.

* scanner update API: described in [zmqreceiver.py](gamutrf/zmqreceiver.py). Receives real time scanner updates and config.
* scanner config API: allows RESTful updates to any CLI argument. Eg, ```wget -O- "http://localhost:9001/reconf?freq_start=1e9&freq_end=2e9"``` causes the scanner to reset and scan 1e9 to 2e9Hz. Any config change causes the scanner's gnuradio flowgraph to restart.
* scanner config API: allows RESTful updates to any CLI argument. Eg, ```wget -O- "http://localhost:9001/reconf?freq_start=1e9&freq_end=2e9"``` causes the scanner to reset and scan 1e9 to 2e9Hz. Any config change causes the scanner's gnuradio flowgraph to restart.
2 changes: 1 addition & 1 deletion docs/README-airt.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ install gr-iqtlabs
$ git clone https://github.com/google/flatbuffers -b v23.5.26
$ git clone https://github.com/nlohmann/json -b v3.11.2
$ git clone https://github.com/deepsig/libsigmf -b v1.0.2
$ git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.52
$ git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.53
$ mkdir -p flatbuffers/build && cd flatbuffers/build && cmake -DCMAKE_INSTALL_PREFIX=~/.conda/envs/$CONDA_DEFAULT_ENV .. && make -j $(nproc) && make install && cd ../..
$ mkdir -p json/build && cd json/build && cmake -DCMAKE_INSTALL_PREFIX=~/.conda/envs/$CONDA_DEFAULT_ENV .. && make -j $(nproc) && make install && cd ../..
$ mkdir -p libsigmf/build && cd libsigmf/build && cmake -DUSE_SYSTEM_JSON=ON -DUSE_SYSTEM_FLATBUFFERS=ON -DCMAKE_INSTALL_PREFIX=~/.conda/envs/$CONDA_DEFAULT_ENV -DCMAKE_CXX_FLAGS="-I $HOME/.conda/envs/$CONDA_DEFAULT_ENV/include" .. && make -j $(nproc) && make install && cd ../..
Expand Down
9 changes: 8 additions & 1 deletion gamutrf/grscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def __init__(
):
gr.top_block.__init__(self, "scan", catch_exceptions=True)

tune_step_hz = int(samp_rate * tuneoverlap)

if freq_end == 0:
freq_end = freq_start + (tune_step_hz - 1)
logging.info(
f"using stare mode, scan from {freq_start/1e6}MHz to {freq_end/1e6}MHz"
)

##################################################
# Parameters
##################################################
Expand Down Expand Up @@ -126,7 +134,6 @@ def __init__(
]
)
freq_range = freq_end - freq_start
tune_step_hz = int(samp_rate * tuneoverlap)
fft_rate = int(samp_rate / nfft)

if not tune_step_fft:
Expand Down
11 changes: 6 additions & 5 deletions gamutrf/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def argument_parser():
dest="freq_end",
type=eng_float,
default=eng_notation.num_to_str(MAX_FREQ),
help="Set freq_end [default=%(default)r]",
help="Set freq_end [default=%(default)r] (if 0, configure stare mode at --freq-start)",
)
parser.add_argument(
"--freq-start",
Expand Down Expand Up @@ -380,11 +380,12 @@ def check_options(options):
if options.samp_rate % options.nfft:
print("NFFT should be a factor of sample rate")

if options.freq_start > options.freq_end:
return "freq_start must be less than freq_end"
if options.freq_end:
if options.freq_start > options.freq_end:
return "freq_start must be less than freq_end"

if options.freq_end > 6e9:
return "freq_end must be less than 6GHz"
if options.freq_end > 6e9:
return "freq_end must be less than 6GHz"

if options.freq_start < 10e6:
return "freq_start must be at least 10MHz"
Expand Down
2 changes: 1 addition & 1 deletion gamutrf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# https://files.ettus.com/manual/page_transport.html
# https://github.com/EttusResearch/uhd/blob/master/host/lib/usrp/b200/b200_impl.hpp
# Should result in no overflows:
# UHD_IMAGES_DIR=/usr/share/uhd/images ./examples/rx_samples_to_file --args num_recv_frames=960,recv_frame_size=16360 --file test.gz --nsamps 200000000 --rate 20000000 --freq 101e6 --spb 20000000
# UHD_IMAGES_DIR=/usr/share/uhd/images ./examples/rx_samples_to_file --args num_recv_frames=1000,recv_frame_size=16360 --file test.gz --nsamps 200000000 --rate 20000000 --freq 101e6 --spb 20000000
ETTUS_ARGS = "num_recv_frames=1000,recv_frame_size=16360,type=b200"
ETTUS_ANT = "TX/RX"
SAMPLE_FILENAME_RE = re.compile(r"^.+\D(\d+)_(\d+)Hz_(\d+)sps\.c*([fisu]\d+|raw).*$")
Expand Down
9 changes: 7 additions & 2 deletions gamutrf/waterfall.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,13 @@ def update_fig(config, state, results):
)
scan_duration = scan_df.ts.max() - scan_df.ts.min()
tune_count = scan_df.tune_count.max()
tune_rate_hz = tune_count / scan_duration
tune_dwell_ms = (scan_duration * 1e3) / tune_count

if scan_duration:
tune_rate_hz = tune_count / scan_duration
tune_dwell_ms = (scan_duration * 1e3) / tune_count
else:
tune_rate_hz = 0
tune_dwell_ms = 0
idx = (
((scan_df.freq - config.min_freq) / config.freq_resolution)
.round()
Expand Down
23 changes: 13 additions & 10 deletions orchestrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ services:
devices:
- /dev/bus/usb:/dev/bus/usb
- /dev/dri/renderD128:/dev/dri/renderD128
# Uncomment when using Nvidia GPU (container toolkit etc must be installed)
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: 1
# capabilities: [gpu]
# nvidia container toolkit etc must be installed.
# Comment out "deploy" if on non-x86 platform (e.g. Pi4)
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
volumes:
- '${VOL_PREFIX}:/logs'
command:
Expand All @@ -68,9 +69,11 @@ services:
- --use_external_gps
- --use_external_heading
- --inference_min_confidence=0.8
- --inference_min_db=-50
- --inference_min_db=-80
- --inference_model_name=mini2_snr
- --inference_output_dir=/logs/inference
# - --external_gps_server=1.2.3.4
# - --external_gps_server_port=8888
# - --inference_output_dir=/logs/inference
# - --inference_model_server=torchserve:8080
healthcheck:
test: [CMD, "/gamutrf/bin/scanhc.sh", "9000"]
Expand Down

0 comments on commit 084b181

Please sign in to comment.