From 09bcde5b4eaa4af5cb6f88f2ccb213fda6c58c27 Mon Sep 17 00:00:00 2001 From: ha7ilm Date: Wed, 14 Jun 2017 11:57:32 +0200 Subject: [PATCH] Updated README and added bpsk31_ber.py --- README.md | 24 ++++++++++++------- grc_tests/bpsk31_ber.py | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 9 deletions(-) create mode 100755 grc_tests/bpsk31_ber.py diff --git a/README.md b/README.md index 1bdc57e..c0997c7 100755 --- a/README.md +++ b/README.md @@ -1,14 +1,20 @@ -libcsdr -======= +CSDR +==== + +`csdr` is a command line tool to carry out DSP tasks for Software Defined Radio. + +It can be used to build simple signal processing flow graphs, right from the command line. + +The included `libcsdr` library contains the DSP functions that `csdr` makes use of. It was designed to use auto-vectorization available in `gcc`, and also has some functions optimized with inline assembly for ARM NEON to achieve some speedup by taking advantage of SIMD command sets available in today's CPUs. -*libcsdr* is a set of simple DSP routines for Software Defined Radio. -It is mostly useful for AM/FM/SSB demodulation and spectrum display. Feel free to use it in your projects. Most of the code is available under the permissive BSD license, with some optional parts under GPL. For additional details, see licensing. -- The package comes with a command-line tool `csdr`, which lets you build DSP processing chains by shell pipes. -- The code of *libcsdr* was intended to be easy to follow. -- *libcsdr* was designed to use auto-vectorization available in *gcc*. It means that it can achieve some speedup by taking advantage of SIMD command sets available in today's CPUs (e.g. SSE on x86 and NEON on ARM). +`csdr` has already been used to build: + +- AM/FM/SSB/CW demodulators, BPSK31 decoder and waterfall display in [OpenWebRX](https://github.com/simonyiszk/openwebrx), +- AM/FM/SSB modulators in [qtcsdr](https://github.com/ha7ilm/qtcsdr) that can also be used standalone with [rpitx](https://github.com/ha7ilm/rpitx-app-note), +- a decoder for FSK transmissions sent with the CC1111 wireless MCU, and also a standalone RTTY demodulator. How to compile -------------- @@ -22,11 +28,11 @@ If you compile on ARM, please edit the Makefile and tailor `PARAMS_NEON` for you To run the examples, you will also need rtl_sdr from Osmocom, and the following packages (at least on Debian): `mplayer octave gnuplot gnuplot-x11` -If you compile *fftw3* from sources for use with *libcsdr*, you need to configure it with 32-bit float support enabled: +If you compile `fftw3` from sources for use with `libcsdr`, you need to configure it with 32-bit float support enabled: ./configure --enable-float -(This is for *fftw3*, not *libcsdr*. You do not need to run the configure script before compiling *libcsdr*.) +(This is for `fftw3`, not `libcsdr`. You do not need to run the configure script before compiling `libcsdr`.) Credits ------- diff --git a/grc_tests/bpsk31_ber.py b/grc_tests/bpsk31_ber.py new file mode 100755 index 0000000..dbfa9d6 --- /dev/null +++ b/grc_tests/bpsk31_ber.py @@ -0,0 +1,53 @@ +#!/usr/bin/python + +import os, time, signal +from subprocess import * +#https://bugs.python.org/issue1652 + +def p(x): + global printcmds + if printcmds: print x + return check_output(x, shell=True) + +printcmds=True + + +def genfiles(snr): + cmd="""(while true; do echo -n 'CQ CQ CQ DE HA7ILM HA7ILM HA7ILM PSE K '; done) | \ +csdr psk31_varicode_encoder_u8_u8 | \ +tee /s/bpsk31_testin | \ +csdr differential_encoder_u8_u8 | \ +csdr psk_modulator_u8_c 2 | \ +csdr psk31_interpolate_sine_cc 256 | \ +csdr awgn_cc %d | \ +csdr timing_recovery_cc GARDNER 256 0.5 2 --add_q | \ +csdr dbpsk_decoder_c_u8 | \ +dd bs=1024 count=10 of=/s/bpsk31_testout +"""%snr + signal.signal(signal.SIGPIPE, signal.SIG_DFL) + if printcmds: print cmd + os.system(cmd) + +def getminsize(): + return min(os.path.getsize("/s/bpsk31_testout"), os.path.getsize("/s/bpsk31_testin")) + +def mkdiff(shift): + if shift==0: + return int(p("cmp -l /s/bpsk31_testin /s/bpsk31_testout | wc -l")) + elif shift<0: + return int(p("(dd if=/dev/zero bs=%d count=1; cat /s/bpsk31_testin)>/s/bpsk31_testin0; cmp -l /s/bpsk31_testin0 /s/bpsk31_testout | wc -l"%-shift)) + elif shift>0: + return int(p("(dd if=/dev/zero bs=%d count=1; cat /s/bpsk31_testout)>/s/bpsk31_testout0; cmp -l /s/bpsk31_testin /s/bpsk31_testout0 | wc -l"%shift)) + + +lf=open("/s/output_results","w") + +for snr in range(0,20,2): + genfiles(snr) + num_totalbits=getminsize() + num_errors=None + for shift in range(-5,5): + curr_num_errors = mkdiff(shift) + if not num_errors or (num_errors and num_errors > curr_num_errors): + num_errors = curr_num_errors + lf.write("%d; %d; %d; %d\n" %(snr, num_errors, num_totalbits, num_errors/float(num_totalbits)))