kopia lustrzana https://github.com/projecthorus/wenet
Add IQ replay script.
rodzic
1ae097f28f
commit
83301c462c
|
@ -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 <vk5qi@rfhead.net>
|
||||
# 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)
|
31
rx/replay.py
31
rx/replay.py
|
@ -1,31 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
import sys, os.path, time
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print("USAGE: python replay.py <samplerate> 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()
|
||||
|
Ładowanie…
Reference in New Issue