backported bugfixes

This commit is contained in:
ha7ilm 2015-05-16 18:09:37 +02:00
parent f388e80624
commit d04e9180d2
6 changed files with 29 additions and 18 deletions

View File

@ -70,7 +70,7 @@ Example DSP commands:
* Decompress FLAC-coded I/Q data:
flac --force-raw-format --decode --endian=little --sign=unsigned - -
'''
watchdog_interval=1.5
watchdog_interval=0
reconnect_interval=10
'''
If there's no input I/Q data after N seconds, input will be filled with zero samples,

View File

@ -1297,8 +1297,8 @@ var color_scale=[0x2e6893ff, 0x69a5d0ff, 0x214b69ff, 0x9dc4e0ff, 0xfff775ff, 0x
function waterfall_mkcolor(db_value)
{
min_value=-100; //in dB
max_value=10
min_value=-115; //in dB
max_value=0
if(db_value<min_value) db_value=min_value
if(db_value>max_value) db_value=max_value
full_scale=max_value-min_value;

View File

@ -219,6 +219,7 @@ def generate_client_id(ip):
new_client.spectrum_queue=Queue.Queue(1000)
new_client.ip=ip
new_client.closed=[False] #byref, not exactly sure if required
new_client.dsp=None
clients_mutex.acquire()
clients.append(new_client)
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
log_client(clients[i],"client being closed.")
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
del clients[i]
if use_mutex: clients_mutex.release()
@ -289,6 +296,7 @@ class WebRXHandler(BaseHTTPRequestHandler):
dsp.set_offset_freq(0)
dsp.set_bpf(-4000,4000)
dsp.start()
myclient.dsp=dsp
while True:
if myclient.closed[0]:

View File

@ -2,6 +2,7 @@ import subprocess
import time
import os
import code
import signal
class dsp_plugin:
@ -26,7 +27,7 @@ class dsp_plugin:
self.demodulator = "nfm"
self.name = "csdr"
try:
subprocess.Popen("nc",stdout=subprocess.PIPE,stderr=subprocess.PIPE)
subprocess.Popen("nc",stdout=subprocess.PIPE,stderr=subprocess.PIPE).kill()
except:
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())
print "[openwebrx-dsp-plugin:csdr] Command =",command
#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
#open control pipes for csdr and send initialization data
@ -121,10 +122,7 @@ class dsp_plugin:
return self.process.stdout.read(size)
def stop(self):
if(self.process!=None):return # returns None while subprocess is running
while(self.process.poll()==None):
self.process.kill()
time.sleep(0.1)
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
os.unlink(self.bpf_pipe)
os.unlink(self.shift_pipe)
self.running = False

View File

@ -87,7 +87,7 @@ def add_data_to_clients(new_data):
elif cfg.cache_full_behaviour == 1:
#rather closing client:
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:
pass #client cache full, just not taking care
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.last_waiting_buffer=""
asyncore.dispatcher.__init__(self, self.client[0].socket[0])
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
def handle_read(self):
global commands
@ -174,6 +175,7 @@ class server_asyncore(asyncore.dispatcher):
self.set_reuse_addr()
self.bind((cfg.my_ip, cfg.my_listening_port))
self.listen(5)
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
log.info("Server listening on port: "+str(cfg.my_listening_port))
def handle_accept(self):
@ -188,7 +190,7 @@ class server_asyncore(asyncore.dispatcher):
my_client[0].ident=max_client_id
max_client_id+=1
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.append(my_client)
clients_mutex.release()
@ -278,9 +280,9 @@ class rtl_tcp_asyncore(asyncore.dispatcher):
if(len(rtl_dongle_identifier)==0):
rtl_dongle_identifier=self.recv(12)
return
new_data_buffer=self.recv(16348)
new_data_buffer=self.recv(1024*16)
if cfg.watchdog_interval:
watchdog_data_count+=16348
watchdog_data_count+=1024*16
if cfg.use_dsp_command:
dsp_input_queue.put(new_data_buffer)
#print "did put anyway"
@ -418,11 +420,13 @@ class client:
socket=None
asyncore=None
def close(self):
def close(self, use_mutex=True):
global clients_mutex
global clients
clients_mutex.acquire()
if use_mutex: clients_mutex.acquire()
correction=0
for i in range(0,len(clients)):
i-=correction
if clients[i][0].ident==self.ident:
try:
self.socket.close()
@ -433,8 +437,9 @@ class client:
del self.asyncore
except:
pass
break
clients_mutex.release()
del clients[i]
correction+=1
if use_mutex: clients_mutex.release()
def main():