backported bugfixes
This commit is contained in:
parent
f388e80624
commit
d04e9180d2
@ -70,7 +70,7 @@ Example DSP commands:
|
|||||||
* Decompress FLAC-coded I/Q data:
|
* Decompress FLAC-coded I/Q data:
|
||||||
flac --force-raw-format --decode --endian=little --sign=unsigned - -
|
flac --force-raw-format --decode --endian=little --sign=unsigned - -
|
||||||
'''
|
'''
|
||||||
watchdog_interval=1.5
|
watchdog_interval=0
|
||||||
reconnect_interval=10
|
reconnect_interval=10
|
||||||
'''
|
'''
|
||||||
If there's no input I/Q data after N seconds, input will be filled with zero samples,
|
If there's no input I/Q data after N seconds, input will be filled with zero samples,
|
||||||
|
@ -53,7 +53,7 @@ center_freq = 145525000
|
|||||||
rf_gain = 5
|
rf_gain = 5
|
||||||
|
|
||||||
start_rtl_thread=True #rtl_sdr is more stable than rtl_tcp...
|
start_rtl_thread=True #rtl_sdr is more stable than rtl_tcp...
|
||||||
start_rtl_command="rtl_sdr -s {samp_rate} -f {center_freq} - | nc -vvl 127.0.0.1 -p 8888".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate)
|
start_rtl_command="rtl_sdr -s {samp_rate} -f {center_freq} - | nc -vvl 127.0.0.1 -p 8888".format(rf_gain=rf_gain, center_freq=center_freq, samp_rate=samp_rate)
|
||||||
#start_rtl_tcp_command="rtl_tcp -s 250000 -f 145525000 -g 0 -p 8888"
|
#start_rtl_tcp_command="rtl_tcp -s 250000 -f 145525000 -g 0 -p 8888"
|
||||||
#You can use other SDR hardware as well, but if the command above outputs samples in a format other than [unsigned char], then the dsp plugin has to be slightly modified (at the csdr convert_u8_f part).
|
#You can use other SDR hardware as well, but if the command above outputs samples in a format other than [unsigned char], then the dsp plugin has to be slightly modified (at the csdr convert_u8_f part).
|
||||||
|
|
||||||
|
@ -1297,8 +1297,8 @@ var color_scale=[0x2e6893ff, 0x69a5d0ff, 0x214b69ff, 0x9dc4e0ff, 0xfff775ff, 0x
|
|||||||
|
|
||||||
function waterfall_mkcolor(db_value)
|
function waterfall_mkcolor(db_value)
|
||||||
{
|
{
|
||||||
min_value=-100; //in dB
|
min_value=-115; //in dB
|
||||||
max_value=10
|
max_value=0
|
||||||
if(db_value<min_value) db_value=min_value
|
if(db_value<min_value) db_value=min_value
|
||||||
if(db_value>max_value) db_value=max_value
|
if(db_value>max_value) db_value=max_value
|
||||||
full_scale=max_value-min_value;
|
full_scale=max_value-min_value;
|
||||||
|
@ -219,6 +219,7 @@ def generate_client_id(ip):
|
|||||||
new_client.spectrum_queue=Queue.Queue(1000)
|
new_client.spectrum_queue=Queue.Queue(1000)
|
||||||
new_client.ip=ip
|
new_client.ip=ip
|
||||||
new_client.closed=[False] #byref, not exactly sure if required
|
new_client.closed=[False] #byref, not exactly sure if required
|
||||||
|
new_client.dsp=None
|
||||||
clients_mutex.acquire()
|
clients_mutex.acquire()
|
||||||
clients.append(new_client)
|
clients.append(new_client)
|
||||||
log_client(new_client,"client added. Clients now: {0}".format(len(clients)))
|
log_client(new_client,"client added. Clients now: {0}".format(len(clients)))
|
||||||
@ -231,6 +232,12 @@ def close_client(i, use_mutex=True):
|
|||||||
global clients
|
global clients
|
||||||
log_client(clients[i],"client being closed.")
|
log_client(clients[i],"client being closed.")
|
||||||
if use_mutex: clients_mutex.acquire()
|
if use_mutex: clients_mutex.acquire()
|
||||||
|
try:
|
||||||
|
clients[i].dsp.stop()
|
||||||
|
except:
|
||||||
|
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||||
|
print "[openwebrx] close_client dsp.stop() :: error -",exc_type,exc_value
|
||||||
|
traceback.print_tb(exc_traceback)
|
||||||
clients[i].closed[0]=True
|
clients[i].closed[0]=True
|
||||||
del clients[i]
|
del clients[i]
|
||||||
if use_mutex: clients_mutex.release()
|
if use_mutex: clients_mutex.release()
|
||||||
@ -289,6 +296,7 @@ class WebRXHandler(BaseHTTPRequestHandler):
|
|||||||
dsp.set_offset_freq(0)
|
dsp.set_offset_freq(0)
|
||||||
dsp.set_bpf(-4000,4000)
|
dsp.set_bpf(-4000,4000)
|
||||||
dsp.start()
|
dsp.start()
|
||||||
|
myclient.dsp=dsp
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if myclient.closed[0]:
|
if myclient.closed[0]:
|
||||||
|
@ -2,6 +2,7 @@ import subprocess
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import code
|
import code
|
||||||
|
import signal
|
||||||
|
|
||||||
class dsp_plugin:
|
class dsp_plugin:
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ class dsp_plugin:
|
|||||||
self.demodulator = "nfm"
|
self.demodulator = "nfm"
|
||||||
self.name = "csdr"
|
self.name = "csdr"
|
||||||
try:
|
try:
|
||||||
subprocess.Popen("nc",stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
subprocess.Popen("nc",stdout=subprocess.PIPE,stderr=subprocess.PIPE).kill()
|
||||||
except:
|
except:
|
||||||
print "[openwebrx-plugin:csdr] error: netcat not found, please install netcat!"
|
print "[openwebrx-plugin:csdr] error: netcat not found, please install netcat!"
|
||||||
|
|
||||||
@ -106,7 +107,7 @@ class dsp_plugin:
|
|||||||
command=command_base.format(bpf_pipe=self.bpf_pipe,shift_pipe=self.shift_pipe,decimation=self.decimation,last_decimation=self.last_decimation,fft_size=self.fft_size,fft_block_size=self.fft_block_size(),bpf_transition_bw=float(self.bpf_transition_bw)/self.if_samp_rate(),ddc_transition_bw=self.ddc_transition_bw())
|
command=command_base.format(bpf_pipe=self.bpf_pipe,shift_pipe=self.shift_pipe,decimation=self.decimation,last_decimation=self.last_decimation,fft_size=self.fft_size,fft_block_size=self.fft_block_size(),bpf_transition_bw=float(self.bpf_transition_bw)/self.if_samp_rate(),ddc_transition_bw=self.ddc_transition_bw())
|
||||||
print "[openwebrx-dsp-plugin:csdr] Command =",command
|
print "[openwebrx-dsp-plugin:csdr] Command =",command
|
||||||
#code.interact(local=locals())
|
#code.interact(local=locals())
|
||||||
self.process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
|
self.process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True, preexec_fn=os.setpgrp)
|
||||||
self.running = True
|
self.running = True
|
||||||
|
|
||||||
#open control pipes for csdr and send initialization data
|
#open control pipes for csdr and send initialization data
|
||||||
@ -121,10 +122,7 @@ class dsp_plugin:
|
|||||||
return self.process.stdout.read(size)
|
return self.process.stdout.read(size)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if(self.process!=None):return # returns None while subprocess is running
|
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
|
||||||
while(self.process.poll()==None):
|
|
||||||
self.process.kill()
|
|
||||||
time.sleep(0.1)
|
|
||||||
os.unlink(self.bpf_pipe)
|
os.unlink(self.bpf_pipe)
|
||||||
os.unlink(self.shift_pipe)
|
os.unlink(self.shift_pipe)
|
||||||
self.running = False
|
self.running = False
|
||||||
|
21
rtl_mus.py
21
rtl_mus.py
@ -87,7 +87,7 @@ def add_data_to_clients(new_data):
|
|||||||
elif cfg.cache_full_behaviour == 1:
|
elif cfg.cache_full_behaviour == 1:
|
||||||
#rather closing client:
|
#rather closing client:
|
||||||
log.error("client cache full, dropping client: "+str(client[0].ident)+"@"+client[0].socket[1][0])
|
log.error("client cache full, dropping client: "+str(client[0].ident)+"@"+client[0].socket[1][0])
|
||||||
client[0].close()
|
client[0].close(False)
|
||||||
elif cfg.cache_full_behaviour == 2:
|
elif cfg.cache_full_behaviour == 2:
|
||||||
pass #client cache full, just not taking care
|
pass #client cache full, just not taking care
|
||||||
else: log.error("invalid value for cfg.cache_full_behaviour")
|
else: log.error("invalid value for cfg.cache_full_behaviour")
|
||||||
@ -131,6 +131,7 @@ class client_handler(asyncore.dispatcher):
|
|||||||
self.sent_dongle_id=False
|
self.sent_dongle_id=False
|
||||||
self.last_waiting_buffer=""
|
self.last_waiting_buffer=""
|
||||||
asyncore.dispatcher.__init__(self, self.client[0].socket[0])
|
asyncore.dispatcher.__init__(self, self.client[0].socket[0])
|
||||||
|
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||||
|
|
||||||
def handle_read(self):
|
def handle_read(self):
|
||||||
global commands
|
global commands
|
||||||
@ -174,6 +175,7 @@ class server_asyncore(asyncore.dispatcher):
|
|||||||
self.set_reuse_addr()
|
self.set_reuse_addr()
|
||||||
self.bind((cfg.my_ip, cfg.my_listening_port))
|
self.bind((cfg.my_ip, cfg.my_listening_port))
|
||||||
self.listen(5)
|
self.listen(5)
|
||||||
|
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||||
log.info("Server listening on port: "+str(cfg.my_listening_port))
|
log.info("Server listening on port: "+str(cfg.my_listening_port))
|
||||||
|
|
||||||
def handle_accept(self):
|
def handle_accept(self):
|
||||||
@ -188,7 +190,7 @@ class server_asyncore(asyncore.dispatcher):
|
|||||||
my_client[0].ident=max_client_id
|
my_client[0].ident=max_client_id
|
||||||
max_client_id+=1
|
max_client_id+=1
|
||||||
my_client[0].start_time=time.time()
|
my_client[0].start_time=time.time()
|
||||||
my_client[0].waiting_data=multiprocessing.Queue(250)
|
my_client[0].waiting_data=multiprocessing.Queue(500)
|
||||||
clients_mutex.acquire()
|
clients_mutex.acquire()
|
||||||
clients.append(my_client)
|
clients.append(my_client)
|
||||||
clients_mutex.release()
|
clients_mutex.release()
|
||||||
@ -278,9 +280,9 @@ class rtl_tcp_asyncore(asyncore.dispatcher):
|
|||||||
if(len(rtl_dongle_identifier)==0):
|
if(len(rtl_dongle_identifier)==0):
|
||||||
rtl_dongle_identifier=self.recv(12)
|
rtl_dongle_identifier=self.recv(12)
|
||||||
return
|
return
|
||||||
new_data_buffer=self.recv(16348)
|
new_data_buffer=self.recv(1024*16)
|
||||||
if cfg.watchdog_interval:
|
if cfg.watchdog_interval:
|
||||||
watchdog_data_count+=16348
|
watchdog_data_count+=1024*16
|
||||||
if cfg.use_dsp_command:
|
if cfg.use_dsp_command:
|
||||||
dsp_input_queue.put(new_data_buffer)
|
dsp_input_queue.put(new_data_buffer)
|
||||||
#print "did put anyway"
|
#print "did put anyway"
|
||||||
@ -418,11 +420,13 @@ class client:
|
|||||||
socket=None
|
socket=None
|
||||||
asyncore=None
|
asyncore=None
|
||||||
|
|
||||||
def close(self):
|
def close(self, use_mutex=True):
|
||||||
global clients_mutex
|
global clients_mutex
|
||||||
global clients
|
global clients
|
||||||
clients_mutex.acquire()
|
if use_mutex: clients_mutex.acquire()
|
||||||
|
correction=0
|
||||||
for i in range(0,len(clients)):
|
for i in range(0,len(clients)):
|
||||||
|
i-=correction
|
||||||
if clients[i][0].ident==self.ident:
|
if clients[i][0].ident==self.ident:
|
||||||
try:
|
try:
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
@ -433,8 +437,9 @@ class client:
|
|||||||
del self.asyncore
|
del self.asyncore
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
break
|
del clients[i]
|
||||||
clients_mutex.release()
|
correction+=1
|
||||||
|
if use_mutex: clients_mutex.release()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user