can record sdr samples, spectrum, rtl_fm demod, postprocessing

needs refactoring
This commit is contained in:
Paul Brewer KI6CQ 2014-10-17 19:12:33 +00:00
parent d4198d81ea
commit bc34995d68
1 changed files with 67 additions and 22 deletions

View File

@ -1,10 +1,47 @@
import math
import time import time
import pypredict import pypredict
import subprocess import subprocess
children = []
def pollall():
global children
try:
dead = [child for child in children if child.poll() is not None];
for child in dead:
children.remove(child)
except Exception as e:
print "Exception: "+str(e)
def runForDuration(cmdline, duration):
try:
child = subprocess.Popen(cmdline)
time.sleep(duration)
child.terminate()
except OSError as e:
print "OS Error during command: "+" ".join(cmdline)
print "OS Error: "+e.strerror
def recordSDR(freq, fname, duration):
sdrOffset = -50000
sdrRate = 20800*11
cmdline = ['rtl_sdr',\
'-f', str(freq+sdrOffset),\
'-s', str(sdrRate),\
fname+'.sdr']
runForDuration(cmdline, duration)
def decode(fname): def decode(fname):
cmdline = ['/root/atpdec-1.7/atpdec',fname+'.wav'] # cmdline = ['atpdec',fname+'.wav']
subprocess.call(cmdline) # subprocess.call(cmdline)
cmdline = ['python','-m','cqwx.APT',fname+'X5.wav',fname+'R.png',fname+'F.png']
try:
children.append(subprocess.Popen(cmdline)) # run in background
except OSError as e:
print e.strerror
def spectrum(fname,freq,duration): def spectrum(fname,freq,duration):
flow = freq - 10000 flow = freq - 10000
@ -24,41 +61,48 @@ satellites = [\
{'name': 'NOAA-15',\ {'name': 'NOAA-15',\
'freq': 137620000,\ 'freq': 137620000,\
'postProcess': decode },\ 'postProcess': decode },\
{'name': 'OSCAR-50',\ {'name': 'OSCAR-7',\
'freq': 436795000, 'freq': 145950000, \
'listen': spectrum, 'listen': recordSDR },\
},\ {'name': 'FUNCUBE-1',\
{'name': 'ISS',\ 'freq': 145950000, \
'freq': 145800000 }\ 'listen': recordSDR },\
{'name': 'OSCAR-29',
'freq': 435850000, \
'listen': recordSDR },\
# {'name': 'OSCAR-50',\
# 'freq': 436795000,\
# },\
# {'name': 'ISS',\
# 'freq': 145800000 }\
] ]
sample = '44100' sample = '20800'
wavrate='11025' wavrate='11025'
wav5rate ='20800'
def runForDuration(cmdline, duration):
try:
child = subprocess.Popen(cmdline)
time.sleep(duration)
child.terminate()
except OSError as e:
print "OS Error during command: "+" ".join(cmdline)
print "OS Error: "+e.strerror
def recordFM(freq, fname, duration): def recordFM(freq, fname, duration):
# still experimenting with options - unsure as to best settings # still experimenting with options - unsure as to best settings
cmdline = ['rtl_fm',\ cmdline = ['rtl_fm',\
'-f',str(freq),\ '-f',str(freq),\
'-s',sample,\ '-s',sample,\
'-g', '47',\
'-F','9',\ '-F','9',\
'-A','fast',\ # '-A','fast',\
'-E','dc',\ '-E','dc',\
fname+'.raw'] fname+'.raw']
runForDuration(cmdline, duration) runForDuration(cmdline, duration)
def transcode(fname): def transcode(fname):
cmdline = ['sox','-t','raw','-r',sample,'-es','-b','16','-c','1','-V1',fname+'.raw',fname+'.wav','rate',wavrate] # todolist = [('.wav', wavrate), ('X5.wav', wav5rate)]
subprocess.call(cmdline) todolist = [('X5.wav', wav5rate)]
for (ext,rate) in todolist:
try:
cmdline = ['sox','-t','raw','-r',sample,'-es','-b','16','-c','1','-V1',fname+'.raw',fname+ext,'rate',rate]
subprocess.call(cmdline)
except OSError, e:
print "OSError on :"+" ".join(cmdline)
print "OSError:"+e.strerror
def recordWAV(freq,fname,duration): def recordWAV(freq,fname,duration):
recordFM(freq,fname,duration) recordFM(freq,fname,duration)
@ -72,6 +116,7 @@ def findNextPass():
predictions[nextIndex]) predictions[nextIndex])
while True: while True:
pollall()
(sat, (aosTime, losTime)) = findNextPass() (sat, (aosTime, losTime)) = findNextPass()
satName = sat['name'] satName = sat['name']
freq = sat['freq'] freq = sat['freq']