Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ nmux
ddcd
*.o
*.so
*.so.*
tags
dumpvect.*.vect
grc_tests/top_block.py
*.swp
csdrpy.i
csdrpy.py*
csdrpy_wrap.*
25 changes: 23 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ PARAMS_MISC = -Wno-unused-result
#PARAMS_DEBUG = $(if $(DEBUG_ON),-g,)
FFTW_PACKAGE = fftw-3.3.3
PREFIX ?= /usr
PYVERSION ?= 2.7
SOVERSION = 0.15

.PHONY: clean-vect clean
.PHONY: clean-vect clean-python clean
all: csdr nmux
libcsdr.so: fft_fftw.c fft_rpi.c libcsdr_wrapper.c libcsdr.c libcsdr_gpl.c fastddc.c fastddc.h fft_fftw.h fft_rpi.h ima_adpcm.h libcsdr_gpl.h libcsdr.h predefined.h
@echo NOTE: you may have to manually edit Makefile to optimize for your CPU \(especially if you compile on ARM, please edit PARAMS_NEON\).
Expand All @@ -66,7 +67,7 @@ arm-cross: clean-vect
arm-linux-gnueabihf-gcc -std=gnu99 -O3 -fshort-double -ffast-math -dumpbase dumpvect-arm -fdump-tree-vect-details -mfloat-abi=softfp -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mvectorize-with-neon-quad -Wno-unused-result -Wformat=0 $(SOURCES) -lm -o ./csdr
clean-vect:
rm -f dumpvect*.vect
clean: clean-vect
clean: clean-vect clean-python
rm -f libcsdr.so.$(SOVERSION) csdr ddcd nmux *.o *.so
install: all
install -m 0755 libcsdr.so.$(SOVERSION) $(PREFIX)/lib
Expand Down Expand Up @@ -99,3 +100,23 @@ emcc:
cat sdr.js/sdrjs-header.js sdr.js/sdrjs-compiled.js sdr.js/sdrjs-footer.js > sdr.js/sdr.js
emcc-beautify:
bash -c 'type js-beautify >/dev/null 2>&1; if [ $$? -eq 0 ]; then js-beautify sdr.js/sdr.js >sdr.js/sdr.js.beautiful; mv sdr.js/sdr.js.beautiful sdr.js/sdr.js; fi'

python: libcsdr.so clean-python
@echo "/* This file is autogenerated. Any changes should be made to csdrpy.i.in */" > csdrpy.i
@echo 'generating "csdrpy.i"'
@cat csdrpy.i.in >> csdrpy.i
@cat fastddc.h >> csdrpy.i
@cat fft_fftw.h >> csdrpy.i
@cat fft_rpi.h >> csdrpy.i
@cat ima_adpcm.h >> csdrpy.i
@cat libcsdr_gpl.h >> csdrpy.i
@cat libcsdr.h >> csdrpy.i
swig -python csdrpy.i
gcc -c -fPIC csdrpy_wrap.c -I/usr/include/python$(PYVERSION) -I.
gcc -shared csdrpy_wrap.o -L. -lcsdr -lfftw3f -lm -o _csdrpy.so

clean-python:
rm -f csdrpy_wrap.c csdrpy_wrap.o _csdrpy.so csdrpy.py* csdrpy.i

python-install: libcsdr.so
install -m 0755 csdrpy.py _csdrpy.so $(PREFIX)/lib/python$(PYVERSION)/
21 changes: 21 additions & 0 deletions csdrpy.i.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
%module csdrpy

%{
#define SWIG_FILE_WITH_INIT
#define LIBCSDR_GPL
#define USE_FFTW
#define USE_IMA_ADPCM

#include "predefined.h"
#include "fastddc.h"
#include "libcsdr.h"
#include "libcsdr_gpl.h"
#include "fft_fftw.h"
#include "fft_rpi.h"
#include "ima_adpcm.h"
%}

%feature("autodoc", "2");

/* contents of libcsdr.h will be appended below for processing by swig */

14 changes: 14 additions & 0 deletions csdrpy_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python

import csdrpy

csdrpy_syms = filter(lambda x: x.startswith('_') == False, dir(csdrpy))
csdrpy_syms = set(csdrpy_syms)

assert( csdrpy.is_nan(1.0) == False)
assert( csdrpy.is_nan(float('NaN')) == True)
assert( csdrpy.log2n(1) == 0 )
assert( csdrpy.log2n(256) == 8)

print 'Loaded {0} symbols'.format(len(csdrpy_syms))
print 'csdr python binding works! :)'