From 06bad0221199c91a296e7bc1306e628809ec693f Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 6 May 2019 10:47:54 +0200 Subject: [PATCH] Frequency Tracker script updates --- scriptsapi/Readme.md | 18 +++++++++++++++++- scriptsapi/freqtracking.py | 15 ++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) mode change 100644 => 100755 scriptsapi/freqtracking.py diff --git a/scriptsapi/Readme.md b/scriptsapi/Readme.md index f596f7c5a..3d0662844 100644 --- a/scriptsapi/Readme.md +++ b/scriptsapi/Readme.md @@ -10,4 +10,20 @@ pip install -r requirements.txt # Install requirements

freqtracking.py

-This script is used to achieve frequency tracking with the FreqTracker plugin. \ No newline at end of file +This script is used to achieve frequency tracking with the FreqTracker plugin. Ideally you would start it before connecting the Frequency Tracker plugin in SDRangel. It works continuously (daemon style) until stop via Ctl-C. + +Options are: + + - `-h` or `--help` show help message and exit + - `-A` or `--address` listening address (default `0.0.0.0`) + - `-P` or `--port` listening port (default `8888`) + - `-a` or `--address-sdr` SDRangel REST API address (defaults to calling address) + - `-p` or `--port-sdr` SDRangel REST API port (default `8091`) + +With default options (no parameters) it will listen on all available interfaces including loopback at `127.0.0.1` and at port `8888`. It will identify the SDRangel API address with the first request from SDRangel and connect back at port `8091`. + +Normal sequence of operations: + + - Start `freqtracking.py` in a terminal + - In SDRangel connect the Frequency Tracker plugin by clicking on the grey square at the left of the top bar of the Frequency Tracker GUI. It opens the channel settings dialog. Check the 'Reverse API' box. Next to this box is the address and port at which the channel will be connected. If you use the defaults for `freqtracking.py` you may leave it as it is else you have to adjust it to the address and port of `freqtracking.py` (options `-A` and `-P`). + - In the same manner connect the channel you want to be controlled by `freqtracking.py`. You may connect any number of channels like this. When a channel is removed `freqtracking.py` will automatically remove it from its list at the first attempt to synchronize that will fail. diff --git a/scriptsapi/freqtracking.py b/scriptsapi/freqtracking.py old mode 100644 new mode 100755 index e0baabf90..5bcdf1a61 --- a/scriptsapi/freqtracking.py +++ b/scriptsapi/freqtracking.py @@ -44,7 +44,7 @@ def getInputOptions(): if options.addr == None: options.addr = "0.0.0.0" if options.port == None: - options.port = 8000 + options.port = 8888 if options.sdrangel_port == None: options.sdrangel_port = 8091 @@ -112,7 +112,16 @@ def adjust_channels(sdrangel_ip, sdrangel_port): if r.status_code / 100 != 2: remove_keys.append(k) for k in remove_keys: - TRACKING_DICT.pop(k, None) + tracking_item = TRACKING_DICT.pop(k, None) + if tracking_item: + request_content = tracking_item.get('requestContent') + if request_content: + channel_type = request_content.get('channelType') + else: + channel_type = 'Undefined' + device_index = k[0] + channel_index = k[1] + print(f'SDRangel: {sdrangel_ip}:{sdrangel_port} Removed {channel_type} [{device_index}:{channel_index}]') # ====================================================================== @@ -158,7 +167,7 @@ def channel_settings(deviceset_index, channel_index): channel_type = content.get('channelType') for freq_offset in gen_dict_extract('inputFrequencyOffset', content): if channel_type == "FreqTracker": - print(f'SDRangel: {sdrangel_ip}:{SDRANGEL_API_PORT} Tracker: {freq_offset} Hz') + print(f'SDRangel: {sdrangel_ip}:{SDRANGEL_API_PORT} Tracker [{orig_device_index}:{orig_channel_index}] at {freq_offset} Hz') TRACKER_OFFSET = freq_offset TRACKER_DEVICE = orig_device_index adjust_channels(sdrangel_ip, SDRANGEL_API_PORT)