can record sdr samples, spectrum, rtl_fm demod, postprocessing
needs refactoring
This commit is contained in:
parent
d4198d81ea
commit
bc34995d68
|
@ -1,10 +1,47 @@
|
|||
import math
|
||||
import time
|
||||
import pypredict
|
||||
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):
|
||||
cmdline = ['/root/atpdec-1.7/atpdec',fname+'.wav']
|
||||
subprocess.call(cmdline)
|
||||
# cmdline = ['atpdec',fname+'.wav']
|
||||
# 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):
|
||||
flow = freq - 10000
|
||||
|
@ -24,41 +61,48 @@ satellites = [\
|
|||
{'name': 'NOAA-15',\
|
||||
'freq': 137620000,\
|
||||
'postProcess': decode },\
|
||||
{'name': 'OSCAR-50',\
|
||||
'freq': 436795000,
|
||||
'listen': spectrum,
|
||||
},\
|
||||
{'name': 'ISS',\
|
||||
'freq': 145800000 }\
|
||||
{'name': 'OSCAR-7',\
|
||||
'freq': 145950000, \
|
||||
'listen': recordSDR },\
|
||||
{'name': 'FUNCUBE-1',\
|
||||
'freq': 145950000, \
|
||||
'listen': recordSDR },\
|
||||
{'name': 'OSCAR-29',
|
||||
'freq': 435850000, \
|
||||
'listen': recordSDR },\
|
||||
# {'name': 'OSCAR-50',\
|
||||
# 'freq': 436795000,\
|
||||
# },\
|
||||
# {'name': 'ISS',\
|
||||
# 'freq': 145800000 }\
|
||||
]
|
||||
|
||||
sample = '44100'
|
||||
sample = '20800'
|
||||
wavrate='11025'
|
||||
|
||||
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
|
||||
wav5rate ='20800'
|
||||
|
||||
def recordFM(freq, fname, duration):
|
||||
# still experimenting with options - unsure as to best settings
|
||||
cmdline = ['rtl_fm',\
|
||||
'-f',str(freq),\
|
||||
'-s',sample,\
|
||||
'-g', '47',\
|
||||
'-F','9',\
|
||||
'-A','fast',\
|
||||
# '-A','fast',\
|
||||
'-E','dc',\
|
||||
fname+'.raw']
|
||||
runForDuration(cmdline, duration)
|
||||
|
||||
def transcode(fname):
|
||||
cmdline = ['sox','-t','raw','-r',sample,'-es','-b','16','-c','1','-V1',fname+'.raw',fname+'.wav','rate',wavrate]
|
||||
subprocess.call(cmdline)
|
||||
|
||||
# todolist = [('.wav', wavrate), ('X5.wav', wav5rate)]
|
||||
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):
|
||||
recordFM(freq,fname,duration)
|
||||
|
@ -72,6 +116,7 @@ def findNextPass():
|
|||
predictions[nextIndex])
|
||||
|
||||
while True:
|
||||
pollall()
|
||||
(sat, (aosTime, losTime)) = findNextPass()
|
||||
satName = sat['name']
|
||||
freq = sat['freq']
|
||||
|
|
Loading…
Reference in New Issue