Skip to content

Commit 994f219

Browse files
authored
Merge pull request #936 from ke5gdb/testing
Use unique SSRC for scan routine
2 parents 81143b1 + 4757169 commit 994f219

File tree

4 files changed

+35
-15
lines changed

4 files changed

+35
-15
lines changed

auto_rx/autorx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# MINOR - New sonde type support, other fairly big changes that may result in telemetry or config file incompatability issus.
1313
# PATCH - Small changes, or minor feature additions.
1414

15-
__version__ = "1.8.0-beta1"
15+
__version__ = "1.8.0-beta2"
1616

1717
# Global Variables
1818

auto_rx/autorx/ka9q.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,23 @@
1616
def ka9q_setup_channel(
1717
sdr_hostname,
1818
frequency,
19-
sample_rate
19+
sample_rate,
20+
scan
2021
):
22+
if scan:
23+
ssrc="04"
24+
else:
25+
ssrc="01"
26+
2127
# tune --samprate 48000 --frequency 404m09 --mode iq --ssrc 404090000 --radio sonde.local
2228
_cmd = (
2329
f"{timeout_cmd()} 5 " # Add a timeout, because connections to non-existing servers block for ages
2430
f"tune "
2531
f"--samprate {int(sample_rate)} "
2632
f"--mode iq "
27-
f"--low {int(sample_rate) / (-2.4)} --high {int(sample_rate) / 2.4} "
33+
f"--low {int(int(sample_rate) / (-2.4))} --high {int(int(sample_rate) / 2.4)} "
2834
f"--frequency {int(frequency)} "
29-
f"--ssrc {round(frequency / 1000)}01 "
35+
f"--ssrc {round(frequency / 1000)}{ssrc} "
3036
f"--radio {sdr_hostname}"
3137
)
3238

@@ -62,16 +68,21 @@ def ka9q_setup_channel(
6268

6369
def ka9q_close_channel(
6470
sdr_hostname,
65-
frequency
71+
frequency,
72+
scan
6673
):
74+
if scan:
75+
ssrc="04"
76+
else:
77+
ssrc="01"
6778

6879
_cmd = (
6980
f"{timeout_cmd()} 5 " # Add a timeout, because connections to non-existing servers block for ages
7081
f"tune "
7182
f"--samprate 48000 "
7283
f"--mode iq "
7384
f"--frequency 0 "
74-
f"--ssrc {round(frequency / 1000)}01 "
85+
f"--ssrc {round(frequency / 1000)}{ssrc} "
7586
f"--radio {sdr_hostname}"
7687
)
7788

@@ -108,11 +119,16 @@ def ka9q_close_channel(
108119
def ka9q_get_iq_cmd(
109120
sdr_hostname,
110121
frequency,
111-
sample_rate
122+
sample_rate,
123+
scan
112124
):
125+
if scan:
126+
ssrc="04"
127+
else:
128+
ssrc="01"
113129

114130
# We need to setup a channel before we can use it!
115-
_setup_success = ka9q_setup_channel(sdr_hostname, frequency, sample_rate)
131+
_setup_success = ka9q_setup_channel(sdr_hostname, frequency, sample_rate, scan)
116132

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

auto_rx/autorx/scan.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ def detect_sonde(
330330
bias = bias,
331331
sdr_hostname = sdr_hostname,
332332
sdr_port = sdr_port,
333-
ss_iq_path = ss_iq_path
333+
ss_iq_path = ss_iq_path,
334+
scan = True
334335
)
335336

336337
# rx_test_command = (
@@ -436,7 +437,7 @@ def detect_sonde(
436437
ret_output = ret_output.decode("utf8")
437438

438439
# Release the SDR channel if necessary
439-
shutdown_sdr(sdr_type, rtl_device_idx, sdr_hostname, frequency)
440+
shutdown_sdr(sdr_type, rtl_device_idx, sdr_hostname, frequency, scan=True)
440441

441442
except subprocess.CalledProcessError as e:
442443
# dft_detect returns a code of 1 if no sonde is detected.

auto_rx/autorx/sdr_wrappers.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ def shutdown_sdr(
245245
sdr_type: str,
246246
sdr_id: str,
247247
sdr_hostname = "",
248-
frequency: int = None
248+
frequency: int = None,
249+
scan: bool = False,
249250
):
250251
"""
251252
Function to trigger shutdown/cleanup of some SDR types.
@@ -257,7 +258,7 @@ def shutdown_sdr(
257258

258259
if sdr_type == "KA9Q":
259260
logging.debug(f"KA9Q - Closing Channel for {sdr_hostname} @ {frequency} Hz.")
260-
ka9q_close_channel(sdr_hostname, frequency)
261+
ka9q_close_channel(sdr_hostname, frequency, scan)
261262
pass
262263
else:
263264
logging.debug(f"No shutdown action required for SDR type {sdr_type}")
@@ -279,7 +280,8 @@ def get_sdr_iq_cmd(
279280
bias = False,
280281
sdr_hostname = "",
281282
sdr_port = 5555,
282-
ss_iq_path = "./ss_iq"
283+
ss_iq_path = "./ss_iq",
284+
scan = False
283285
):
284286
"""
285287
Get a command-line argument to get IQ (signed 16-bit) from a SDR
@@ -301,6 +303,7 @@ def get_sdr_iq_cmd(
301303
Arguments for KA9Q SDR Server / SpyServer:
302304
sdr_hostname (str): Hostname of KA9Q Server
303305
sdr_port (int): Port number of KA9Q Server
306+
scan (bool): Create unique SSRC for scan attempts
304307
305308
Arguments for SpyServer Client:
306309
ss_iq_path (str): Path to spyserver IQ client utility.
@@ -358,7 +361,7 @@ def get_sdr_iq_cmd(
358361
return _cmd
359362

360363
if sdr_type == "KA9Q":
361-
_cmd = ka9q_get_iq_cmd(sdr_hostname, frequency, sample_rate)
364+
_cmd = ka9q_get_iq_cmd(sdr_hostname, frequency, sample_rate, scan)
362365

363366
if dc_block:
364367
_cmd += _dc_remove

0 commit comments

Comments
 (0)