From cbab8e18142b2d77213302c92ee5f3ac463d10f2 Mon Sep 17 00:00:00 2001 From: Jono Targett Date: Thu, 11 May 2023 13:18:07 +0930 Subject: [PATCH] Adding missing files from previous commit --- fm_demod.py | 7 +------ formats.py | 18 ++++++++++++++++++ sdrplay_sample | 19 ++----------------- 3 files changed, 21 insertions(+), 23 deletions(-) create mode 100644 formats.py diff --git a/fm_demod.py b/fm_demod.py index 0e08947..d83faff 100755 --- a/fm_demod.py +++ b/fm_demod.py @@ -15,14 +15,9 @@ import numpy as np import filters import argparse import prefixed +from formats import TYPES -TYPES = { - 'CU8': np.uint8, - 'CS16': np.int16, - 'CF32': np.float32, -} - parser = argparse.ArgumentParser() parser.add_argument('-v', '--verbose', help='Print additional informational output', action='store_true') parser.add_argument('-f', '--format', choices=list(TYPES.keys()), help='Input sample format', required=True) diff --git a/formats.py b/formats.py new file mode 100644 index 0000000..ef300e3 --- /dev/null +++ b/formats.py @@ -0,0 +1,18 @@ +import numpy as np +from SoapySDR import SOAPY_SDR_CS16, SOAPY_SDR_CF32 + +FORMATS = { + 'CS16': SOAPY_SDR_CS16, + 'CF32': SOAPY_SDR_CF32, +} + +PACKINGS = { + 'CS16': '=%dh', + 'CF32': '=%df', +} + +TYPES = { + 'CU8': np.uint8, + 'CS16': np.int16, + 'CF32': np.float32, +} \ No newline at end of file diff --git a/sdrplay_sample b/sdrplay_sample index f782c05..96ce6ed 100755 --- a/sdrplay_sample +++ b/sdrplay_sample @@ -8,6 +8,7 @@ import argparse import prefixed from pprint import pprint from colorama import Fore, Style +from formats import FORMATS, PACKINGS, TYPES FREQUENCY = 105500000 @@ -16,21 +17,6 @@ SAMPLE_RATE = 1000000 SAMPLE_COUNT = 0 BLOCK_SIZE = 16384 -FORMATS = { - 'CS16': soapy.SOAPY_SDR_CS16, - 'CF32': soapy.SOAPY_SDR_CF32, -} - -PACKINGS = { - soapy.SOAPY_SDR_CS16: '=%dh', - soapy.SOAPY_SDR_CF32: '=%df', -} - -TYPES = { - soapy.SOAPY_SDR_CS16: np.int16, - soapy.SOAPY_SDR_CF32: np.float32, -} - def get_capabilities(device): def get_direction_capabilities(direction): @@ -125,7 +111,6 @@ if args.d: format = args.format if format is None: format = sdr.getStreamFormats(soapy.SOAPY_SDR_RX, 0)[0] - format = FORMATS[format] if args.verbose: print(f"Frequency: {frequency} Hz", file=sys.stderr) @@ -146,7 +131,7 @@ if args.d: #setup a stream samples = 1000 buffer = np.array([0] * samples * 2, TYPES[format]) - stream = sdr.setupStream(soapy.SOAPY_SDR_RX, format) + stream = sdr.setupStream(soapy.SOAPY_SDR_RX, FORMATS[format]) sdr.activateStream(stream)