ha7ilm / openwebrx

Open source, multi-user SDR receiver software with a web interface
https://sdr.hu/openwebrx
GNU Affero General Public License v3.0
980 stars 462 forks source link

[Q] proper syntax for rx_sdr arguments #134

Closed metssigadus closed 4 years ago

metssigadus commented 4 years ago

Need assistance with nested double quotes in perl syntax of the OpenWebRX configuration file.

In my setup, there are three SDRs. Two of them are SDRPlay's and one is a usual RTL-SDR stick. I have two hosts, the first is the "radio host" which SDRs are connected to, another is the web host running three instances of OpenWebRX. Due to some hidden limitations of the Soapy layer, I administratively set up three SoapyRemote servers at the radio host, on different ports, e.g. 54001, 56001 and 58001. Now, at the web host, I have to address the SDRs very precisely, so that no resource conflict would happen. These are the concurrent commands I used to check the bandwidth and stability (each in own window):

rx_sdr -d "driver=remote,remote=tcp://10.10.1.211:54001,serial=180700D393" - | csdr through > /dev/null rx_sdr -d "driver=remote,remote=tcp://10.10.1.211:56001,serial=180700DC93" - | csdr through > /dev/null rx_sdr -d "driver=remote,remote=tcp://10.10.1.211:58001,serial=01928374" - | csdr through > /dev/null

To connect each OpenWebRX instance to a particular stream, I have tried two options. The first one is to use different device numbers (in accordance with SoapySDRUril --find). Alltogether there are 9 device ID's (3 SDRs x 3 servers) and the syntax is like this rx_sdr -d 8. The choice of the numbers should keep the conflicts away which however is not the case - the Soapy layer still manages to mix the streams. Tired of wondering.

Another option is to duplicate the above driver strings into the OpenWebRX configuration. The gotcha is, the config line is already using the quotation marks. Can you please recommend a proper syntax which will work inside the config_webrx.py file. Unsuccessfully I do not speak Perl. Mimicking the analogy, I tried the following syntax, but it did not work: device_arguments = "driver=remote, remote=tcp://10.10.1.211:56001, serial=180700DC93" start_rtl_command="rx_sdr -d {device_arguments} -F CF32 -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm)

The error: Traceback (most recent call last): File "openwebrx.py", line 737, in main() File "openwebrx.py", line 122, in main cfg=import("config_webrx" if no_arguments else sys.argv[1]) File "/home/air/SRV/Instance_02/config_webrx.py", line 151, in start_rtl_command="rx_sdr -d {device_arguments} -F CF32 -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm) KeyError: 'device_arguments'

metssigadus commented 4 years ago

OK guys, obviously Perl!=Python, but both are unknown to me languages starting with letter P.

Many thnx to @laurivosandi for an elegant answer. The sought syntax is here: start_rtl_command="rx_sdr -d {device_arguments} -F CF32 -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate, ppm=ppm, device_arguments = repr("driver=remote, remote=tcp://10.10.1.148:54001, serial=180700D393") )

You may now close this issue.