/fsdr-cli

FutureSDR command line interface

Primary LanguageRustApache License 2.0Apache-2.0

fsdr-cli

A command line interface based on FutureSDR meant to be

  • a line-for-line replacement of csdr (original),
  • yet able to pack pipelined command in one unique-flowgraph,
  • with new commands and expression evaluation,
  • able to launch simple GNU Radio Companion flowgraph within FutureSDR runtime,
  • a testing tool for FutureSDR community blocks

Features:

  • csdr retrocompatibility: ongoing
  • GNU Radio flowgraph execution: ongoing
  • all in one flow graph execution: single process, no more pipes!
  • expression evaluation
  • conversion of csdr commands into GNU Radio companion flowgraph wherever possible
  • additional commands

WFM decoding

In the csdr documentation about WFM demodulation, one can find the following command line:

rtl_sdr -s 240000 -f 89500000 -g 20 - | csdr convert_u8_f | csdr fmdemod_quadri_cf | csdr fractional_decimator_ff 5 | csdr deemphasis_wfm_ff 48000 50e-6 | csdr convert_f_s16 | mplayer -cache 1024 -quiet -rawaudio samplesize=2:channels=1:rate=48000 -demuxer rawaudio -

Does it works with fsdr-cli? For sure! Just replace every csdr with fsdr-cli:

rtl_sdr -s 240000 -f 89500000 -g 20 - | fsdr-cli convert_u8_f | fsdr-cli fmdemod_quadri_cf | fsdr-cli fractional_decimator_ff 5 | fsdr-cli deemphasis_wfm_ff 48000 50e-6 | fsdr-cli convert_f_s16 | mplayer -cache 1024 -quiet -rawaudio samplesize=2:channels=1:rate=48000 -demuxer rawaudio -

But is it the most efficient way? No. One can benefit from FutureSDR efficient scheduling. You just need to transform it as such:

rtl_sdr -s 240000 -f 89500000 -g 20 - | fsdr-cli csdr convert_u8_f ! convert_ff_c ! fmdemod_quadri_cf ! fractional_decimator_ff 5 ! deemphasis_wfm_ff 48000 50e-6 ! convert_f_s16 | mplayer -cache 1024 -quiet -rawaudio samplesize=2:channels=1:rate=48000 -demuxer rawaudio -

Bascially, it is just a matter of replacing pipe | with ! (escaping pipeline \| is also working) so that your shell does not interpret them, and asking fsdr-cli to interpret the command line as a multi-block of csdr command. There is also one newly inserted block convert_ff_c due to otherwise ill-typed workflow.

And by the way, why use mplayer for sound output? There is also an audio command:

rtl_sdr -s 240000 -f 89500000 -g 20 - | fsdr-cli csdr convert_u8_f ! convert_ff_c ! fmdemod_quadri_cf ! fractional_decimator_ff 5 ! deemphasis_wfm_ff 48000 50e-6 ! audio "48_000" 1

But maybe you are more used to GNURadio and would have come with the following workflow chain1.grc:

Well, it also works:

fsdr-cli grc tests/chain1.grc

All would run fine (even keeping the blocks' name):

$ ./target/release/fsdr-cli grc tests/chain1.grc 
$ ./target/debug/fsdr-cli grc tests/chain1.grc 
FutureSDR: DEBUG - in run_flowgraph
FutureSDR: DEBUG - Listening on 127.0.0.1:1337
FutureSDR: DEBUG - connect stream io
FutureSDR: DEBUG - connect message io
FutureSDR: DEBUG - init blocks
FutureSDR: DEBUG - wait for blocks init
FutureSDR: DEBUG - running blocks
FutureSDR: DEBUG - blocks_file_source_0 terminating 
FutureSDR: DEBUG - blocks_char_to_float_0 terminating 
FutureSDR: DEBUG - blocks_deinterleave_0 terminating 
FutureSDR: DEBUG - blocks_float_to_complex_0 terminating 
FutureSDR: DEBUG - analog_quadrature_demod_cf_0 terminating 
FutureSDR: DEBUG - rational_resampler_xxx_0 terminating 
FutureSDR: DEBUG - analog_fm_deemph_0 terminating 
FutureSDR: DEBUG - blocks_float_to_short_0 terminating 
FutureSDR: DEBUG - blocks_file_sink_0 terminating 
FutureSDR: DEBUG - blocks_throttle_0 terminating 
FutureSDR: DEBUG - audio_sink_0 terminating

NFM Decoding

fsdr-cli csdr load_c tests/test-nfm.c32 ! fir_decimate_cc 10 0.005 HAMMING ! fmdemod_quadri_cf ! limit_ff ! deemphasis_nfm_ff 48000 ! agc_ff ! audio 48000 1

AM Decoding

fsdr-cli csdr load_u8 tests/test-am.u8 ! convert_u8_f ! convert_ff_c ! shift_addition_cc "((145M-144M400)/2_400_000)" ! fir_decimate_cc 16 0.005 HAMMING ! amdemod_cf ! fastdcblock_ff ! agc_ff ! limit_ff ! audio "48_000" 1

Oh by the way, did you notice that you no longer need python? Look at the shift_addition_cc parameter. Everywhere one can provide a value can also now provide an expression given it is in bracket "()". Due to bash rules, you may be required to surround them with quotes. You can also use constants pi, e, nan, inf, neg_inf, tau wherever appropriate.

One can also use multipliers notation like 145M500 would be interpreted as 145500000. Valid multipliers are K, M, and G. Also _ can be used as a separator to ease lisibility, eg 145_500_000.

SSB decoding

Just like with csdr, one can simulate analog circuit with following commands to demodulate LSB:

fsdr-cli csdr load_c tests/ssb_lsb_256k_complex2.dat ! shift_addition_cc "(-51500/256000)" ! fir_decimate_cc "(256000/48000)" 0.005 HAMMING ! bandpass_fir_fft_cc -0.1 0.0 0.05 ! realpart_cf ! agc_ff ! limit_ff ! audio 48_000 1

Reminder:

  • bandpass_fir_fft_cc 0 0.1 for USB
  • bandpass_fir_fft_cc -0.1 0 for LSB

Yet, thanks to newly added weaver_lsb_cf and weaver_usb_cf we may have better result with following commands line:

fsdr-cli csdr load_c tests/ssb_lsb_256k_complex2.dat ! shift_addition_cc "(-51500/256000)" ! rational_resampler_cc 48000 256000 ! weaver_usb_cf "(1500/48000)" ! gain_ff 0.00000008 ! limit_ff ! audio 48_000 1

TODO

So much more to experiment with! Just come to help. ;-

commands

Syntax:

audio rate num_inputs
audio "48_000" 1

Create a sink from an audio device. The sink has num_inputs floating streams as inputs.

Not all audio rate will be supported by your device, nor num_inputs. fsdr-cli will try his best to find a compatible one but better for you to adapt the flowgraph.

Syntax:

load_u8 filename
load_f filename
load_c filename

Use the file as input.

Syntax:

rational_resampler_cc interp decim

Resample stream based on rational ratio: interp/decim, just like rational_resampler_ff but on complex stream.

Syntax:

weaver_usb_cf mid_audio_freq_rate
weaver_lsb_cf mid_audio_freq_rate

weaver_usb_cf "(1500/48000)"

Apply weaver method for SSB decoding. Usually one take 1500Hz as the center of the audible audio bandwidth. Basically it acts as following flowgraph:

Footnotes

  1. Used in SSB demodulation 2 3 4 5 6

  2. Used in NFM demodulation 2 3 4 5

  3. Used in AM demodulation 2 3 4 5 6

  4. Used in simple WFM demodulation 2 3