Skip to content

Commit

Permalink
Merge pull request #986 from projecthorus/testing
Browse files Browse the repository at this point in the history
v1.8.1 Release - RS41 Multi-GNSS Support, ka9q-radio updates
  • Loading branch information
darksidelemm authored Feb 21, 2025
2 parents 35d9515 + 73cc869 commit 8b6e2f2
Show file tree
Hide file tree
Showing 15 changed files with 363 additions and 166 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:

- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:qemu-v8.1.5

- name: Setup Buildx
uses: docker/setup-buildx-action@v3
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN apt-get update && \
libbsd-dev \
libfftw3-dev \
libiniparser-dev \
libogg-dev \
libopus-dev && \
rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -61,11 +62,11 @@ RUN git clone https://github.com/miweber67/spyserver_client.git /root/spyserver_
# Compile ka9q-radio from source
RUN git clone https://github.com/ka9q/ka9q-radio.git /root/ka9q-radio && \
cd /root/ka9q-radio && \
git checkout ff7fe26a12909317b26bdb24a0576db87c15baf2 && \
git checkout d0febaa033e1d53b9b53078cfe17457ac3676d20 && \
make \
-f Makefile.linux \
"COPTS=-std=gnu11 -pthread -Wall -funsafe-math-optimizations -fno-math-errno -fcx-limited-range -D_GNU_SOURCE=1" \
tune powers pcmcat
ARCHOPTS= \
tune powers pcmrecord

# Copy in radiosonde_auto_rx.
COPY . /root/radiosonde_auto_rx
Expand Down Expand Up @@ -118,7 +119,7 @@ RUN ln -s ss_client /opt/auto_rx/ss_iq && \
# Copy ka9q-radio utilities
COPY --from=build /root/ka9q-radio/tune /usr/local/bin/
COPY --from=build /root/ka9q-radio/powers /usr/local/bin/
COPY --from=build /root/ka9q-radio/pcmcat /usr/local/bin/
COPY --from=build /root/ka9q-radio/pcmrecord /usr/local/bin/

# Allow mDNS resolution for ka9q-radio utilities
RUN sed -i -e 's/files dns/files mdns4_minimal [NOTFOUND=return] dns/g' /etc/nsswitch.conf
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Improvements from the upstream RS codebase will be merged into this codebase whe
Please consider joining the Google Group to receive updates on new software features:
https://groups.google.com/forum/#!forum/radiosonde_auto_rx

We also have a channel in the SondeHub Discord server: https://sondehub.org/go/discord

## Presentations
* Linux.conf.au 2019 - https://www.youtube.com/watch?v=YBy-bXEWZeM
* UKHAS Conference 2019 - [Presented via Skype](https://youtu.be/azDJmMywBgw?t=643) which had some audio issues at the start. Slides [here](https://rfhead.net/sondes/auto_rx_presentation_UKHAS2019.pdf).
Expand Down
2 changes: 1 addition & 1 deletion auto_rx/autorx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# MINOR - New sonde type support, other fairly big changes that may result in telemetry or config file incompatability issus.
# PATCH - Small changes, or minor feature additions.

__version__ = "1.8.0"
__version__ = "1.8.1"

# Global Variables

Expand Down
30 changes: 15 additions & 15 deletions auto_rx/autorx/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,9 +829,10 @@ def generate_decoder_command_experimental(self):
_baud_rate = 4800
_sample_rate = 48000 # 10x Oversampling

# Limit FSK estimator window to roughly +/- 10 kHz
_lower = -10000
_upper = 10000
# Limit FSK estimator window to roughly +/- 5 kHz
_lower = -5000
_upper = 5000


demod_cmd = get_sdr_iq_cmd(
sdr_type = self.sdr_type,
Expand All @@ -844,14 +845,17 @@ def generate_decoder_command_experimental(self):
ppm = self.ppm,
gain = self.gain,
bias = self.bias,
dc_block = True
dc_block = True,
channel_filter = 5000 # +/- 5 kHz channel filter.
)

# Add in tee command to save IQ to disk if debugging is enabled.
if self.save_decode_iq:
demod_cmd += f" tee {self.save_decode_iq_path} |"

demod_cmd += "./fsk_demod --cs16 -b %d -u %d -s --stats=%d 2 %d %d - -" % (
# Use a 4800 Hz mask estimator to better avoid adjacent sonde issues.
# Also seems to give a small performance bump.
demod_cmd += "./fsk_demod --cs16 -b %d -u %d -s --mask 4800 --stats=%d 2 %d %d - -" % (
_lower,
_upper,
_stats_rate,
Expand Down Expand Up @@ -949,15 +953,9 @@ def generate_decoder_command_experimental(self):
_baud_rate = 2500
_sample_rate = 50000 # 10x Oversampling

# Limit FSK estimator window to roughly +/- 10 kHz
_lower = -10000
_upper = 10000

if (abs(403200000 - self.sonde_freq) < 20000) and (self.sdr_type == "RTLSDR"):
# Narrow up the frequency estimator window if we are close to
# the 403.2 MHz RTLSDR Spur.
_lower = -8000
_upper = 8000
# Limit FSK estimator window to roughly +/- 5 kHz
_lower = -5000
_upper = 5000

demod_cmd = get_sdr_iq_cmd(
sdr_type = self.sdr_type,
Expand All @@ -970,14 +968,16 @@ def generate_decoder_command_experimental(self):
ppm = self.ppm,
gain = self.gain,
bias = self.bias,
dc_block = True
dc_block = True,
channel_filter = 5000
)

# Add in tee command to save IQ to disk if debugging is enabled.
if self.save_decode_iq:
demod_cmd += f" tee {self.save_decode_iq_path} |"

# NOTE - Using inverted soft decision outputs, so DFM type detection works correctly.
# No mask estimator - DFMs seem to decode better without it!
demod_cmd += "./fsk_demod --cs16 -b %d -u %d -s -i --stats=%d 2 %d %d - -" % (
_lower,
_upper,
Expand Down
27 changes: 19 additions & 8 deletions auto_rx/autorx/ka9q.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,29 @@ def ka9q_setup_channel(
sdr_hostname,
frequency,
sample_rate,
scan
scan,
channel_filter = None
):
if scan:
ssrc="04"
else:
ssrc="01"

# tune --samprate 48000 --frequency 404m09 --mode iq --ssrc 404090000 --radio sonde.local

if channel_filter:
_low = int(channel_filter * -1.0)
_high = int(channel_filter)
else:
_low = int(int(sample_rate) / (-2.4))
_high = int(int(sample_rate) / 2.4)

_cmd = (
f"{timeout_cmd()} 5 " # Add a timeout, because connections to non-existing servers block for ages
f"tune "
f"--samprate {int(sample_rate)} "
f"--mode iq "
f"--low {int(int(sample_rate) / (-2.4))} --high {int(int(sample_rate) / 2.4)} "
f"--low {_low} --high {_high} "
f"--frequency {int(frequency)} "
f"--ssrc {round(frequency / 1000)}{ssrc} "
f"--radio {sdr_hostname}"
Expand Down Expand Up @@ -120,28 +129,30 @@ def ka9q_get_iq_cmd(
sdr_hostname,
frequency,
sample_rate,
scan
scan,
channel_filter = None
):
if scan:
ssrc="04"
else:
ssrc="01"

# We need to setup a channel before we can use it!
_setup_success = ka9q_setup_channel(sdr_hostname, frequency, sample_rate, scan)
_setup_success = ka9q_setup_channel(sdr_hostname, frequency, sample_rate, scan, channel_filter)

if not _setup_success:
logging.critical(f"KA9Q ({sdr_hostname}) - Could not setup rx channel! Decoder will likely timeout.")

# Get the 'PCM' version of the server name, where as assume -pcm is added to the first part of the hostname.
_pcm_host = sdr_hostname.split('.')[0] + "-pcm." + ".".join(sdr_hostname.split(".")[1:])

# Example: pcmcat -s 404090000 sonde-pcm.local
# Example: pcmrecord --ssrc 404090001 --catmode --raw sonde-pcm.local
# -2 option was removed sometime in early 2024.
_cmd = (
f"pcmcat "
f"-s {round(frequency / 1000)}{ssrc} "
f"-b 1 "
f"pcmrecord "
f"--ssrc {round(frequency / 1000)}{ssrc} "
f"--catmode "
f"--raw "
f"{_pcm_host} |"
)

Expand Down
8 changes: 1 addition & 7 deletions auto_rx/autorx/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,7 @@ def detect_sonde(
_if_bw = 64
else:
_iq_bw = 48000
_if_bw = 20

# Try and avoid the RTLSDR 403.2 MHz spur.
# Note that this is only goign to work if we are detecting on 403.210 or 403.190 MHz.
if (abs(403200000 - frequency) < 20000) and (sdr_type == "RTLSDR"):
logging.debug("Scanner - Narrowing detection IF BW to avoid RTLSDR spur.")
_if_bw = 15
_if_bw = 15

else:
# 1680 MHz sondes
Expand Down
17 changes: 9 additions & 8 deletions auto_rx/autorx/sdr_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_sdr(
ss_iq_path = "./ss_iq",
ss_power_path = "./ss_power",
check_freq = 401500000,
timeout = 5
timeout = 20
):
"""
Test the prescence / functionality of a SDR.
Expand Down Expand Up @@ -60,8 +60,8 @@ def test_sdr(
# if not os.path.isfile('tune'):
# logging.critical("Could not find KA9Q-Radio 'tune' binary! This may need to be compiled and installed.")
# return False
# if not os.path.isfile('pcmcat'):
# logging.critical("Could not find KA9Q-Radio 'pcmcat' binary! This may need to be compiled and installed.")
# if not os.path.isfile('pcmrecord'):
# logging.critical("Could not find KA9Q-Radio 'pcmrecord' binary! This may need to be compiled and installed.")
# return False
# TBD - whatever we need for spectrum use.
# if not os.path.isfile('TBD'):
Expand Down Expand Up @@ -281,7 +281,8 @@ def get_sdr_iq_cmd(
sdr_hostname = "",
sdr_port = 5555,
ss_iq_path = "./ss_iq",
scan = False
scan = False,
channel_filter = None
):
"""
Get a command-line argument to get IQ (signed 16-bit) from a SDR
Expand All @@ -303,7 +304,8 @@ def get_sdr_iq_cmd(
Arguments for KA9Q SDR Server / SpyServer:
sdr_hostname (str): Hostname of KA9Q Server
sdr_port (int): Port number of KA9Q Server
scan (bool): Create unique SSRC for scan attempts
scan (bool): Create unique SSRC for scan attempts (KA9Q Only)
channel_filter (int/float): Set a high/lowpass frequency for a KA9Q channel.
Arguments for SpyServer Client:
ss_iq_path (str): Path to spyserver IQ client utility.
Expand Down Expand Up @@ -361,9 +363,9 @@ def get_sdr_iq_cmd(
return _cmd

if sdr_type == "KA9Q":
_cmd = ka9q_get_iq_cmd(sdr_hostname, frequency, sample_rate, scan)
_cmd = ka9q_get_iq_cmd(sdr_hostname, frequency, sample_rate, scan, channel_filter)

if dc_block:
if dc_block and ("KA9Q" not in sdr_type):
_cmd += _dc_remove

return _cmd
Expand Down Expand Up @@ -779,7 +781,6 @@ def get_power_spectrum(
_ssrc = f"{round(_center_freq / 1000)}03"

_powers_cmd = (
f"LANG=C " # temporary workaround for https://github.com/ka9q/ka9q-radio/pull/65#issuecomment-2480243690
f"{_timeout_cmd} {ka9q_powers_path} "
f"{sdr_hostname} "
f"-f {_center_freq} "
Expand Down
Loading

0 comments on commit 8b6e2f2

Please sign in to comment.