From 83301c462c3c979cc0f905493ff40cbf1545f0b7 Mon Sep 17 00:00:00 2001 From: Mark Jessop Date: Sat, 27 Jul 2019 13:35:02 +0930 Subject: [PATCH] Add IQ replay script. --- rx/play_iq.py | 35 +++++++++++++++++++++++++++++++++++ rx/replay.py | 31 ------------------------------- 2 files changed, 35 insertions(+), 31 deletions(-) create mode 100644 rx/play_iq.py delete mode 100644 rx/replay.py diff --git a/rx/play_iq.py b/rx/play_iq.py new file mode 100644 index 0000000..1faec8d --- /dev/null +++ b/rx/play_iq.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# +# IQ Test Script +# +# Play back an IQ file at a user-supplied rate. +# IQ file must be in 8-bit complex format (i.e. the output from rtl_sdr) +# +# Run using: +# python play_iq.py ../test_iq/test_images.bin 1000000 | ./fsk_demod --cu8 -s 2 921416 115177 - - | ./drs232_ldpc - - -vv | python rx_ssdv.py --partialupdate 16 +# +# Copyright (C) 2019 Mark Jessop +# Released under GNU GPL v3 or later +# + +import sys +import time + +# Check if we are running in Python 2 or 3 +PY3 = sys.version_info[0] == 3 + +filename = sys.argv[1] +rate = int(sys.argv[2]) + +with open(filename,'rb') as in_file: + while True: + # Read in N samples from the file. + data = in_file.read(rate*2) + + if PY3: + sys.stdout.buffer.write(data) + else: + sys.stdout.write(data) + + sys.stdout.flush() + time.sleep(1) diff --git a/rx/replay.py b/rx/replay.py deleted file mode 100644 index 168d0ec..0000000 --- a/rx/replay.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python -import sys, os.path, time - -if len(sys.argv) != 3: - print("USAGE: python replay.py filename.bin") - -file_name = sys.argv[2] -sample_rate = int(sys.argv[1]) - -if not os.path.exists(file_name): - print("File does not exist.") - sys.exit(0) - -file_size = os.path.getsize(file_name) - -block_size = sample_rate/10 - -f = open(file_name, 'rb') - -while file_size > 0: - if file_size > block_size: - samples = f.read(block_size) - file_size -= block_size - else: - samples = f.read() - - sys.stdout.write(samples) - time.sleep(0.1) - -f.close() -