Quick Tip: Use kiwirecorder.py to Automate Recordings & Evade Inactivity Time-Outs

If you’re like me and only recently discovered the beauty of KiwiSDR, you might have encountered a few niggles with monitoring transmissions over longer periods in the form of time-outs. One of the more annoying time-outs is the inactivity time-out which has no clear indication when it would sneak up on you before suddenly …

… cutting out and “eating” your recording along with it. While such time-outs serve to free-up slots from people who have probably forgotten about their OpenWebRX instance in the background, it is utterly annoying for those who are trying to catch a whole program of Shortwave Radiogram (for example) which runs for 30 minutes. Even SDRs with 30 minute inactivity timeouts cause issues, as we’d always want to tune in early …

kiwirecorder.py to the Rescue

If you’ve read my earlier posting about using kiwifax.py for receiving radiofax via KiwiSDRs, then you would be familiar with the process of obtaining and using the kiwiclient set of tools. To use it, you will need a working Python 2.x installation and numpy – under Windows, it’s easiest to use WinPython 2.7.10.3 in my experience.

Learning about how to use kiwirecorder.py is as simple as opening the command prompt and executing python kiwirecorder.py –help

Usage: kiwirecorder.py [options]

Options:
  -h, --help            show this help message and exit
  --log=LOG_LEVEL, --log-level=LOG_LEVEL, --log_level=LOG_LEVEL
                        Log level: debug|info|warn(default)|error|critical
  -q, --quiet           Don't print progress messages
  -k SOCKET_TIMEOUT, --socket-timeout=SOCKET_TIMEOUT, --socket_timeout=SOCKET_TIMEOUT
                        Timeout(sec) for sockets
  -s SERVER_HOST, --server-host=SERVER_HOST
                        Server host (can be a comma-delimited list)
  -p SERVER_PORT, --server-port=SERVER_PORT
                        Server port, default 8073 (can be a comma delimited
                        list)
  --pw=PASSWORD, --password=PASSWORD
                        Kiwi login password (if required, can be a comma
                        delimited list)
  -u USER, --user=USER  Kiwi connection user name
  --launch-delay=LAUNCH_DELAY, --launch_delay=LAUNCH_DELAY
                        Delay (secs) in launching multiple connections
  -f FREQUENCY, --freq=FREQUENCY
                        Frequency to tune to, in kHz (can be a comma-separated
                        list)
  -m MODULATION, --modulation=MODULATION
                        Modulation; one of am, lsb, usb, cw, nbfm, iq
  --ncomp, --no_compression
                        Don't use audio compression
  --dt-sec=DT           Start a new file when mod(sec_of_day,dt) == 0
  -L LP_CUT, --lp-cutoff=LP_CUT
                        Low-pass cutoff frequency, in Hz
  -H HP_CUT, --hp-cutoff=HP_CUT
                        Low-pass cutoff frequency, in Hz
  --fn=FILENAME, --filename=FILENAME
                        Use fixed filename instead of generated filenames
                        (optional station ID(s) will apply)
  --station=STATION     Station ID to be appended (can be a comma-separated
                        list)
  -d DIR, --dir=DIR     Optional destination directory for files
  -w, --kiwi-wav        Use wav file format including KIWI header (GPS time-
                        stamps) only for IQ mode
  --kiwi-tdoa           Used when called by Kiwi TDoA extension
  --tlimit=TLIMIT, --time-limit=TLIMIT
                        Record time limit in seconds
  -T THRESH, --squelch-threshold=THRESH
                        Squelch threshold, in dB.
  --squelch-tail=SQUELCH_TAIL
                        Time for which the squelch remains open after the
                        signal is below threshold.
  -g AGC_GAIN, --agc-gain=AGC_GAIN
                        AGC gain; if set, AGC is turned off (can be a comma-
                        separated list)
  -z ZOOM, --zoom=ZOOM  Zoom level 0-14
  --wf                  Process waterfall data instead of audio
  --snd                 Also process sound data when in waterfall mode
  --test-mode           write wav data to /dev/null

The options provided are relatively self-explanatory, but there are only a few you really need to know:

  • -f <frequency in kHz> to tune the receiver to
  • -m <demodulation mode> to decide how to decode the signal
  • –ncomp in case you want higher quality audio without ADPCM compression
  • -u <username> to login to the receiver with – it’s good courtesy to let others know who you are!
  • -s <server address> which is the location of the KiwiSDR receiver you’re trying to use
  • -p <port number> of the KiwiSDR you’re trying to use.

For example, recently I was receiving Shortwave Radiogram from VK6QS in Collie, Western Australia which has a known 20 minute inactivity timeout that causes problems.

No problems today – not with kiwirecorder.py as it isn’t affected by the inactivity timeout. It will, however, lose connection and keep retrying to connect in the case of hitting the daily limit, so use with care and use responsibly!

Interactively, the script prints out block numbers and RSSI as it is recording. To end the recording, kill the process using Crtl+C. You can use the system to automate recordings by invoking the command on a schedule and you could possibly be saving some data as well as it won’t be pulling down user stats/waterfall data if all you want is just the recording.

By default, a reception in USB results in a 16-bit mono .WAV audio file sampled at 12kHz. In other modes (e.g. I-Q), this will differ. There is also the kiwi-wav mode which is useful for TDoA uses as it preserves GPS timestamps but could cause incompatibilities with some players/audio editors.

Conclusion

kiwirecorder.py is another powerful part of the kiwiclient package which makes automating recordings and overcoming the inactivity time-out possible. It is relatively simple to use, as long as you are comfortable with the command line/console, and extremely powerful. Use it responsibly and it will make your “monitoring” life easier.

While the inactivity timeout can serve a purpose, for those who want to avoid users monopolizing the SDR, it’s probably better to set a “daily limit” instead.

At least, with the daily limit, users get a clear indication of how long we have left and using kiwirecorder.py or any other tool won’t allow you to evade this limit. The downside is potentially having problems with users who might be sharing a single IP address also sharing a single daily limit … unfortunately, there is no perfect solution.

I encourage users to use these tools with care in a responsible manner. I’d also encourage users to set their username especially when using these tools as part of being a “good citizen”.

About lui_gough

I'm a bit of a nut for electronics, computing, photography, radio, satellite and other technical hobbies. Click for more about me!
This entry was posted in Computing and tagged , , . Bookmark the permalink.

Error: Comment is Missing!