Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unique SSRC for scan routine #936

Merged
merged 3 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-beta1"
__version__ = "1.8.0-beta2"

# Global Variables

Expand Down
32 changes: 24 additions & 8 deletions auto_rx/autorx/ka9q.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@
def ka9q_setup_channel(
sdr_hostname,
frequency,
sample_rate
sample_rate,
scan
):
if scan:
ssrc="04"
else:
ssrc="01"

# tune --samprate 48000 --frequency 404m09 --mode iq --ssrc 404090000 --radio sonde.local
_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(sample_rate) / (-2.4)} --high {int(sample_rate) / 2.4} "
f"--low {int(int(sample_rate) / (-2.4))} --high {int(int(sample_rate) / 2.4)} "
f"--frequency {int(frequency)} "
f"--ssrc {round(frequency / 1000)}01 "
f"--ssrc {round(frequency / 1000)}{ssrc} "
f"--radio {sdr_hostname}"
)

Expand Down Expand Up @@ -62,16 +68,21 @@ def ka9q_setup_channel(

def ka9q_close_channel(
sdr_hostname,
frequency
frequency,
scan
):
if scan:
ssrc="04"
else:
ssrc="01"

_cmd = (
f"{timeout_cmd()} 5 " # Add a timeout, because connections to non-existing servers block for ages
f"tune "
f"--samprate 48000 "
f"--mode iq "
f"--frequency 0 "
f"--ssrc {round(frequency / 1000)}01 "
f"--ssrc {round(frequency / 1000)}{ssrc} "
f"--radio {sdr_hostname}"
)

Expand Down Expand Up @@ -108,11 +119,16 @@ def ka9q_close_channel(
def ka9q_get_iq_cmd(
sdr_hostname,
frequency,
sample_rate
sample_rate,
scan
):
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)
_setup_success = ka9q_setup_channel(sdr_hostname, frequency, sample_rate, scan)

if not _setup_success:
logging.critical(f"KA9Q ({sdr_hostname}) - Could not setup rx channel! Decoder will likely timeout.")
Expand All @@ -124,7 +140,7 @@ def ka9q_get_iq_cmd(
# -2 option was removed sometime in early 2024.
_cmd = (
f"pcmcat "
f"-s {round(frequency / 1000)}01 "
f"-s {round(frequency / 1000)}{ssrc} "
f"{_pcm_host} |"
)

Expand Down
5 changes: 3 additions & 2 deletions auto_rx/autorx/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ def detect_sonde(
bias = bias,
sdr_hostname = sdr_hostname,
sdr_port = sdr_port,
ss_iq_path = ss_iq_path
ss_iq_path = ss_iq_path,
scan = True
)

# rx_test_command = (
Expand Down Expand Up @@ -436,7 +437,7 @@ def detect_sonde(
ret_output = ret_output.decode("utf8")

# Release the SDR channel if necessary
shutdown_sdr(sdr_type, rtl_device_idx, sdr_hostname, frequency)
shutdown_sdr(sdr_type, rtl_device_idx, sdr_hostname, frequency, scan=True)

except subprocess.CalledProcessError as e:
# dft_detect returns a code of 1 if no sonde is detected.
Expand Down
11 changes: 7 additions & 4 deletions auto_rx/autorx/sdr_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def shutdown_sdr(
sdr_type: str,
sdr_id: str,
sdr_hostname = "",
frequency: int = None
frequency: int = None,
scan: bool = False,
):
"""
Function to trigger shutdown/cleanup of some SDR types.
Expand All @@ -257,7 +258,7 @@ def shutdown_sdr(

if sdr_type == "KA9Q":
logging.debug(f"KA9Q - Closing Channel for {sdr_hostname} @ {frequency} Hz.")
ka9q_close_channel(sdr_hostname, frequency)
ka9q_close_channel(sdr_hostname, frequency, scan)
pass
else:
logging.debug(f"No shutdown action required for SDR type {sdr_type}")
Expand All @@ -279,7 +280,8 @@ def get_sdr_iq_cmd(
bias = False,
sdr_hostname = "",
sdr_port = 5555,
ss_iq_path = "./ss_iq"
ss_iq_path = "./ss_iq",
scan = False
):
"""
Get a command-line argument to get IQ (signed 16-bit) from a SDR
Expand All @@ -301,6 +303,7 @@ 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

Arguments for SpyServer Client:
ss_iq_path (str): Path to spyserver IQ client utility.
Expand Down Expand Up @@ -358,7 +361,7 @@ def get_sdr_iq_cmd(
return _cmd

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

if dc_block:
_cmd += _dc_remove
Expand Down