secondary demod now at least displaying something (and other small fixes)
This commit is contained in:
parent
7732b3f685
commit
f44ff3715f
16
csdr.py
16
csdr.py
@ -93,7 +93,7 @@ class dsp:
|
|||||||
return secondary_chain_base+"csdr realpart_cf | csdr fft_fc {secondary_fft_input_size} {secondary_fft_block_size} | csdr logpower_cf -70 " + (" | csdr compress_fft_adpcm_f_u8 {secondary_fft_size}" if self.fft_compression=="adpcm" else "")
|
return secondary_chain_base+"csdr realpart_cf | csdr fft_fc {secondary_fft_input_size} {secondary_fft_block_size} | csdr logpower_cf -70 " + (" | csdr compress_fft_adpcm_f_u8 {secondary_fft_size}" if self.fft_compression=="adpcm" else "")
|
||||||
elif which == "bpsk31":
|
elif which == "bpsk31":
|
||||||
return secondary_chain_base + "csdr shift_addition_cc --fifo {secondary_shift_pipe} | " + \
|
return secondary_chain_base + "csdr shift_addition_cc --fifo {secondary_shift_pipe} | " + \
|
||||||
"csdr bandpass_fir_fft_cc $(csdr '=-(31.25)/{if_samp_rate}') $(csdr '=(31.25)/{if_samp_rate}') $(csdr '=31.25/{if_samp_rate}') | " + \
|
"csdr bandpass_fir_fft_cc -{secondary_bpf_cutoff} {secondary_bpf_cutoff} {secondary_bpf_cutoff} | " + \
|
||||||
"csdr simple_agc_cc 0.001 0.5 | " + \
|
"csdr simple_agc_cc 0.001 0.5 | " + \
|
||||||
"csdr timing_recovery_cc GARDNER {secondary_samples_per_bits} 0.5 2 --add_q | " + \
|
"csdr timing_recovery_cc GARDNER {secondary_samples_per_bits} 0.5 2 --add_q | " + \
|
||||||
"CSDR_FIXED_BUFSIZE=1 csdr dbpsk_decoder_c_u8 | " + \
|
"CSDR_FIXED_BUFSIZE=1 csdr dbpsk_decoder_c_u8 | " + \
|
||||||
@ -110,12 +110,12 @@ class dsp:
|
|||||||
|
|
||||||
def secondary_bpf_cutoff(self):
|
def secondary_bpf_cutoff(self):
|
||||||
if self.secondary_demodulator == "bpsk31":
|
if self.secondary_demodulator == "bpsk31":
|
||||||
return (31.25/2) / self.if_samp_rate()
|
return 31.25 / self.if_samp_rate()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def secondary_bpf_transition_bw(self):
|
def secondary_bpf_transition_bw(self):
|
||||||
if self.secondary_demodulator == "bpsk31":
|
if self.secondary_demodulator == "bpsk31":
|
||||||
return (31.25/2) / self.if_samp_rate()
|
return 31.25 / self.if_samp_rate()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def secondary_samples_per_bits(self):
|
def secondary_samples_per_bits(self):
|
||||||
@ -171,9 +171,6 @@ class dsp:
|
|||||||
self.set_secondary_offset_freq(self.secondary_offset_freq) #TODO digimodes
|
self.set_secondary_offset_freq(self.secondary_offset_freq) #TODO digimodes
|
||||||
# print "==========> 4"
|
# print "==========> 4"
|
||||||
|
|
||||||
self.set_pipe_nonblocking(self.secondary_process_demod.stdout)
|
|
||||||
self.set_pipe_nonblocking(self.secondary_process_fft.stdout)
|
|
||||||
|
|
||||||
def set_secondary_offset_freq(self, value):
|
def set_secondary_offset_freq(self, value):
|
||||||
self.secondary_offset_freq=value
|
self.secondary_offset_freq=value
|
||||||
if self.secondary_processes_running:
|
if self.secondary_processes_running:
|
||||||
@ -286,7 +283,10 @@ class dsp:
|
|||||||
def get_smeter_level(self):
|
def get_smeter_level(self):
|
||||||
if self.running:
|
if self.running:
|
||||||
line=self.smeter_pipe_file.readline()
|
line=self.smeter_pipe_file.readline()
|
||||||
|
try:
|
||||||
return float(line[:-1])
|
return float(line[:-1])
|
||||||
|
except ValueError:
|
||||||
|
return 0
|
||||||
|
|
||||||
def mkfifo(self,path):
|
def mkfifo(self,path):
|
||||||
try:
|
try:
|
||||||
@ -315,10 +315,6 @@ class dsp:
|
|||||||
try: os.unlink(pipe_path)
|
try: os.unlink(pipe_path)
|
||||||
except Exception as e: print("[openwebrx-dsp-plugin:csdr] try_delete_pipes() ::", e)
|
except Exception as e: print("[openwebrx-dsp-plugin:csdr] try_delete_pipes() ::", e)
|
||||||
|
|
||||||
def set_pipe_nonblocking(self, pipe):
|
|
||||||
flags = fcntl.fcntl(pipe, fcntl.F_GETFL)
|
|
||||||
fcntl.fcntl(pipe, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
command_base=self.chain(self.demodulator)
|
command_base=self.chain(self.demodulator)
|
||||||
|
|
||||||
|
@ -1182,6 +1182,12 @@ function on_ws_recv(evt)
|
|||||||
waterfall_init();
|
waterfall_init();
|
||||||
audio_preinit();
|
audio_preinit();
|
||||||
break;
|
break;
|
||||||
|
case "secondary_config":
|
||||||
|
window.secondary_fft_size = json.value.secondary_fft_size;
|
||||||
|
window.secondary_bw = json.value.secondary_bw;
|
||||||
|
window.if_samp_rate = json.value.if_samp_rate;
|
||||||
|
secondary_demod_init_canvases();
|
||||||
|
break;
|
||||||
case "receiver_details":
|
case "receiver_details":
|
||||||
var r = json.value;
|
var r = json.value;
|
||||||
e('webrx-rx-title').innerHTML = r.receiver_name;
|
e('webrx-rx-title').innerHTML = r.receiver_name;
|
||||||
@ -1236,6 +1242,23 @@ function on_ws_recv(evt)
|
|||||||
audio_buffer_all_size_debug += audio_data.length;
|
audio_buffer_all_size_debug += audio_data.length;
|
||||||
if (!(ios||is_chrome) && (audio_initialized==0 && audio_prepared_buffers.length>audio_buffering_fill_to)) audio_init()
|
if (!(ios||is_chrome) && (audio_initialized==0 && audio_prepared_buffers.length>audio_buffering_fill_to)) audio_init()
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
// secondary FFT
|
||||||
|
if (fft_compression == "none") {
|
||||||
|
secondary_demod_waterfall_add_queue(new Float32Array(data));
|
||||||
|
} else if (fft_compression == "adpcm") {
|
||||||
|
fft_codec.reset();
|
||||||
|
|
||||||
|
var waterfall_i16=fft_codec.decode(new Uint8Array(data));
|
||||||
|
var waterfall_f32=new Float32Array(waterfall_i16.length-COMPRESS_FFT_PAD_N);
|
||||||
|
for(var i=0;i<waterfall_i16.length;i++) waterfall_f32[i]=waterfall_i16[i+COMPRESS_FFT_PAD_N]/100;
|
||||||
|
secondary_demod_waterfall_add_queue(waterfall_f32); //TODO digimodes
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
// secondary demod
|
||||||
|
secondary_demod_push_data(arrayBufferToString(data));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.warn('unknown type of binary message: ' + type)
|
console.warn('unknown type of binary message: ' + type)
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,12 @@ class ClientDataForwarder(object):
|
|||||||
self.conn.send({"type":"smeter","value":level})
|
self.conn.send({"type":"smeter","value":level})
|
||||||
def write_cpu_usage(self, usage):
|
def write_cpu_usage(self, usage):
|
||||||
self.conn.send({"type":"cpuusage","value":usage})
|
self.conn.send({"type":"cpuusage","value":usage})
|
||||||
|
def write_secondary_fft(self, data):
|
||||||
|
self.conn.send(bytes([0x03]) + data)
|
||||||
|
def write_secondary_demod(self, data):
|
||||||
|
self.conn.send(bytes([0x04]) + data)
|
||||||
|
def write_secondary_dsp_config(self, cfg):
|
||||||
|
self.conn.send({"type":"secondary_config", "value":cfg})
|
||||||
|
|
||||||
class WebSocketMessageHandler(object):
|
class WebSocketMessageHandler(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -4,20 +4,22 @@ import threading
|
|||||||
import csdr
|
import csdr
|
||||||
import time
|
import time
|
||||||
|
|
||||||
class RtlNmuxSource(object):
|
class RtlNmuxSource(threading.Thread):
|
||||||
def __init__(self):
|
def run(self):
|
||||||
pm = PropertyManager.getSharedInstance()
|
pm = PropertyManager.getSharedInstance()
|
||||||
|
|
||||||
nmux_bufcnt = nmux_bufsize = 0
|
nmux_bufcnt = nmux_bufsize = 0
|
||||||
while nmux_bufsize < pm.getPropertyValue("samp_rate")/4: nmux_bufsize += 4096
|
while nmux_bufsize < pm.getPropertyValue("samp_rate")/4: nmux_bufsize += 4096
|
||||||
while nmux_bufsize * nmux_bufcnt < pm.getPropertyValue("nmux_memory") * 1e6: nmux_bufcnt += 1
|
while nmux_bufsize * nmux_bufcnt < pm.getPropertyValue("nmux_memory") * 1e6: nmux_bufcnt += 1
|
||||||
if nmux_bufcnt == 0 or nmux_bufsize == 0:
|
if nmux_bufcnt == 0 or nmux_bufsize == 0:
|
||||||
print("[openwebrx-main] Error: nmux_bufsize or nmux_bufcnt is zero. These depend on nmux_memory and samp_rate options in config_webrx.py")
|
print("[RtlNmuxSource] Error: nmux_bufsize or nmux_bufcnt is zero. These depend on nmux_memory and samp_rate options in config_webrx.py")
|
||||||
return
|
return
|
||||||
print("[openwebrx-main] nmux_bufsize = %d, nmux_bufcnt = %d" % (nmux_bufsize, nmux_bufcnt))
|
print("[RtlNmuxSource] nmux_bufsize = %d, nmux_bufcnt = %d" % (nmux_bufsize, nmux_bufcnt))
|
||||||
cmd = pm.getPropertyValue("start_rtl_command") + "| nmux --bufsize %d --bufcnt %d --port %d --address 127.0.0.1" % (nmux_bufsize, nmux_bufcnt, pm.getPropertyValue("iq_server_port"))
|
cmd = pm.getPropertyValue("start_rtl_command") + "| nmux --bufsize %d --bufcnt %d --port %d --address 127.0.0.1" % (nmux_bufsize, nmux_bufcnt, pm.getPropertyValue("iq_server_port"))
|
||||||
subprocess.Popen(cmd, shell=True)
|
self.process = subprocess.Popen(cmd, shell=True)
|
||||||
print("[openwebrx-main] Started rtl source: " + cmd)
|
print("[RtlNmuxSource] Started rtl source: " + cmd)
|
||||||
|
self.process.wait()
|
||||||
|
print("[RtlNmuxSource] shut down")
|
||||||
|
|
||||||
class SpectrumThread(threading.Thread):
|
class SpectrumThread(threading.Thread):
|
||||||
sharedInstance = None
|
sharedInstance = None
|
||||||
@ -63,13 +65,9 @@ class SpectrumThread(threading.Thread):
|
|||||||
print("[openwebrx-spectrum] Note: CSDR_DYNAMIC_BUFSIZE_ON = 1")
|
print("[openwebrx-spectrum] Note: CSDR_DYNAMIC_BUFSIZE_ON = 1")
|
||||||
print("[openwebrx-spectrum] Spectrum thread started.")
|
print("[openwebrx-spectrum] Spectrum thread started.")
|
||||||
bytes_to_read=int(dsp.get_fft_bytes_to_read())
|
bytes_to_read=int(dsp.get_fft_bytes_to_read())
|
||||||
spectrum_thread_counter=0
|
|
||||||
while self.doRun:
|
while self.doRun:
|
||||||
data=dsp.read(bytes_to_read)
|
data=dsp.read(bytes_to_read)
|
||||||
#print("gotcha",len(data),"bytes of spectrum data via spectrum_thread_function()")
|
#print("gotcha",len(data),"bytes of spectrum data via spectrum_thread_function()")
|
||||||
if spectrum_thread_counter >= fft_fps:
|
|
||||||
spectrum_thread_counter=0
|
|
||||||
else: spectrum_thread_counter+=1
|
|
||||||
for c in self.clients:
|
for c in self.clients:
|
||||||
c.write_spectrum_data(data)
|
c.write_spectrum_data(data)
|
||||||
|
|
||||||
@ -138,15 +136,24 @@ class DspManager(object):
|
|||||||
|
|
||||||
if (pm.getPropertyValue("digimodes_enable")):
|
if (pm.getPropertyValue("digimodes_enable")):
|
||||||
def set_secondary_mod(mod):
|
def set_secondary_mod(mod):
|
||||||
|
self.stopSecondaryThreads()
|
||||||
self.dsp.stop()
|
self.dsp.stop()
|
||||||
if mod == False:
|
if mod == False:
|
||||||
self.dsp.set_secondary_demodulator(None)
|
self.dsp.set_secondary_demodulator(None)
|
||||||
else:
|
else:
|
||||||
self.dsp.set_secondary_demodulator(mod)
|
self.dsp.set_secondary_demodulator(mod)
|
||||||
|
self.handler.write_secondary_dsp_config({
|
||||||
|
"secondary_fft_size":pm.getPropertyValue("digimodes_fft_size"),
|
||||||
|
"if_samp_rate":self.dsp.if_samp_rate(),
|
||||||
|
"secondary_bw":self.dsp.secondary_bw()
|
||||||
|
})
|
||||||
# TODO frontend will probably miss this
|
# TODO frontend will probably miss this
|
||||||
#rxws.send(self, "MSG secondary_fft_size={0} if_samp_rate={1} secondary_bw={2} secondary_setup".format(cfg.digimodes_fft_size, dsp.if_samp_rate(), dsp.secondary_bw()))
|
#rxws.send(self, "MSG secondary_fft_size={0} if_samp_rate={1} secondary_bw={2} secondary_setup".format(cfg.digimodes_fft_size, dsp.if_samp_rate(), dsp.secondary_bw()))
|
||||||
self.dsp.start()
|
self.dsp.start()
|
||||||
|
|
||||||
|
if mod:
|
||||||
|
self.startSecondaryThreads()
|
||||||
|
|
||||||
self.localProps.getProperty("secondary_mod").wire(set_secondary_mod)
|
self.localProps.getProperty("secondary_mod").wire(set_secondary_mod)
|
||||||
|
|
||||||
self.localProps.getProperty("secondary_offset_freq").wire(self.dsp.set_secondary_offset_freq)
|
self.localProps.getProperty("secondary_offset_freq").wire(self.dsp.set_secondary_offset_freq)
|
||||||
@ -158,6 +165,18 @@ class DspManager(object):
|
|||||||
threading.Thread(target = self.readDspOutput).start()
|
threading.Thread(target = self.readDspOutput).start()
|
||||||
threading.Thread(target = self.readSMeterOutput).start()
|
threading.Thread(target = self.readSMeterOutput).start()
|
||||||
|
|
||||||
|
def startSecondaryThreads(self):
|
||||||
|
self.runSecondary = True
|
||||||
|
self.secondaryDemodThread = threading.Thread(target = self.readSecondaryDemod)
|
||||||
|
self.secondaryDemodThread.start()
|
||||||
|
self.secondaryFftThread = threading.Thread(target = self.readSecondaryFft)
|
||||||
|
self.secondaryFftThread.start()
|
||||||
|
|
||||||
|
def stopSecondaryThreads(self):
|
||||||
|
self.runSecondary = False
|
||||||
|
self.secondaryDemodThread = None
|
||||||
|
self.secondaryFftThread = None
|
||||||
|
|
||||||
def readDspOutput(self):
|
def readDspOutput(self):
|
||||||
while (self.doRun):
|
while (self.doRun):
|
||||||
data = self.dsp.read(256)
|
data = self.dsp.read(256)
|
||||||
@ -168,6 +187,16 @@ class DspManager(object):
|
|||||||
level = self.dsp.get_smeter_level()
|
level = self.dsp.get_smeter_level()
|
||||||
self.handler.write_s_meter_level(level)
|
self.handler.write_s_meter_level(level)
|
||||||
|
|
||||||
|
def readSecondaryDemod(self):
|
||||||
|
while (self.runSecondary):
|
||||||
|
data = self.dsp.read_secondary_demod(1)
|
||||||
|
self.handler.write_secondary_demod(data)
|
||||||
|
|
||||||
|
def readSecondaryFft(self):
|
||||||
|
while (self.runSecondary):
|
||||||
|
data = self.dsp.read_secondary_fft(int(self.dsp.get_secondary_fft_bytes_to_read()))
|
||||||
|
self.handler.write_secondary_fft(data)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.doRun = False
|
self.doRun = False
|
||||||
self.dsp.stop()
|
self.dsp.stop()
|
||||||
|
@ -30,7 +30,8 @@ def main():
|
|||||||
print(e)
|
print(e)
|
||||||
return
|
return
|
||||||
|
|
||||||
RtlNmuxSource()
|
if (pm.getPropertyValue("start_rtl_thread")):
|
||||||
|
RtlNmuxSource().start()
|
||||||
|
|
||||||
server = ThreadedHttpServer(('0.0.0.0', pm.getPropertyValue("web_port")), RequestHandler)
|
server = ThreadedHttpServer(('0.0.0.0', pm.getPropertyValue("web_port")), RequestHandler)
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
Loading…
Reference in New Issue
Block a user