flrig scripts to switch between radio modes in Windows 10

If you do enough different things with ham radio on Windows, eventually you’ll run into a conflict between programs that can talk to your radio via something like flrig–and those that want the whole COM port to themselves.

Here are some example scripts that switch between 1) a packet radio environment (that uses UZ7HO SoundModem and BPQ32) using direct COM port access, and 2) a “regular” environment, in this case aimed at 20m CW operation. You could set up a script for each of your favorite operating environments if you wanted to.

Hopefully these will be helpful to someone in the future, even as a lot of us move toward Linux (in which case rigctld and rigctl may be more directly useful). Keep in mind that they are not perfect and you should check them line-by-line to make sure they work for you.

For flrig, make sure you have the “Server” port configured (12345 in example) and all the boxes unchecked for “Restore.” These scripts assume you are running them on the same computer your radio is plugged into and flrig is on, otherwise you will have to replace the localhost IP and open the firewall for the port.

The full list of commands can be found here: http://www.w1hkj.com/flrig-help/xmlrpc_server.html. These commands go inside the <methodName></methodName> tags in the XML curl statements. The variable types (e.g. “n:n”) should match these tags that wrap the actual value inside <value></value>: n – nil (?), i – integer (32 bit, s – string, d – double (but I have not tested them all).

For this first draft, I skipped logic and just tried to close and reopen programs so I didn’t have multiple copies running. Timeouts are wait periods in seconds in case there are delays.

Start BPQ32.bat

@echo off

:: Stop BPQ32 if running
taskkill /F /IM BPQMail.exe
taskkill /F /IM bpq32.exe
taskkill /F /IM soundmodem.exe

:: Set up rig
taskkill /IM flrig.exe
timeout 2

start "" "C:\Program Files (x86)\flrig-1.4.5\flrig.exe"
timeout 1
:: Set frequency
curl -X POST -d "<?xml version='1.0'?><methodCall><methodName>rig.set_frequency</methodName><params><param><value><double>14105000</double></value></param></params></methodCall>" http://127.0.0.1:12345

:: Set mode
curl -X POST -d "<?xml version='1.0'?><methodCall><methodName>rig.set_mode</methodName><params><param><value><string>LSB-D</string></value></param></params></methodCall>" http://127.0.0.1:12345

:: Set power
curl -X POST -d "<?xml version='1.0'?><methodCall><methodName>rig.set_power</methodName><params><param><value><int>50</int></value></param></params></methodCall>" http://127.0.0.1:12345

:: Wait
timeout 2

:: Stop flrig
taskkill /IM flrig.exe

:: Wait
timeout 1

:: Start BPQ32
taskkill /F /IM BPQMail.exe
start "" "C:\Program Files (x86)\BPQ32\BPQMail.exe"

exit

Stop BPQ32.bat

@echo off

:: Stop BPQ32
taskkill /F /IM BPQMail.exe
taskkill /F /IM bpq32.exe
taskkill /F /IM soundmodem.exe

:: Wait
timeout 1

:: Start flrig
taskkill /F /IM flrig.exe
timeout 1
start "" "C:\Program Files (x86)\flrig-1.4.5\flrig.exe"
timeout 1

:: Set frequency
curl -X POST -d "<?xml version='1.0'?><methodCall><methodName>rig.set_frequency</methodName><params><param><value><double>14050000</double></value></param></params></methodCall>" http://127.0.0.1:12345

:: Set mode
curl -X POST -d "<?xml version='1.0'?><methodCall><methodName>rig.set_mode</methodName><params><param><value><string>CW</string></value></param></params></methodCall>" http://127.0.0.1:12345

:: Set power
curl -X POST -d "<?xml version='1.0'?><methodCall><methodName>rig.set_power</methodName><params><param><value><int>20</int></value></param></params></methodCall>" http://127.0.0.1:12345

exit 0

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.