From 79caad228e8c0c747778645c331c11f349728fab Mon Sep 17 00:00:00 2001 From: ha7ilm Date: Thu, 23 Jun 2016 11:18:00 +0200 Subject: [PATCH] More debug information (loopstat) --- openwebrx.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/openwebrx.py b/openwebrx.py index 37ead19..45df673 100755 --- a/openwebrx.py +++ b/openwebrx.py @@ -354,7 +354,7 @@ def cleanup_clients(end_all=False): def generate_client_id(ip): #add a client global clients - new_client=namedtuple("ClientStruct", "id gen_time ws_started sprectum_queue ip closed bcastmsg dsp") + new_client=namedtuple("ClientStruct", "id gen_time ws_started sprectum_queue ip closed bcastmsg dsp loopstat") new_client.id=md5.md5(str(random.random())).hexdigest() new_client.gen_time=time.time() new_client.ws_started=False # to check whether client has ever tried to open the websocket @@ -459,6 +459,8 @@ class WebRXHandler(BaseHTTPRequestHandler): access_log("Started streaming to client: "+self.client_address[0]+"#"+myclient.id+" (users now: "+str(len(clients))+")") + myclient.loopstat=0 + while True: if myclient.closed[0]: print "[openwebrx-httpd:ws] client closed by other thread" @@ -466,34 +468,43 @@ class WebRXHandler(BaseHTTPRequestHandler): # ========= send audio ========= if dsp_initialized: + myclient.loopstat=10 temp_audio_data=dsp.read(256) + myclient.loopstat=11 rxws.send(self, temp_audio_data, "AUD ") # ========= send spectrum ========= while not myclient.spectrum_queue.empty(): + myclient.loopstat=20 spectrum_data=myclient.spectrum_queue.get() #spectrum_data_mid=len(spectrum_data[0])/2 #rxws.send(self, spectrum_data[0][spectrum_data_mid:]+spectrum_data[0][:spectrum_data_mid], "FFT ") # (it seems GNU Radio exchanges the first and second part of the FFT output, we correct it) + myclient.loopstat=21 rxws.send(self, spectrum_data[0],"FFT ") # ========= send smeter_level ========= smeter_level=None while True: try: + myclient.loopstat=30 smeter_level=dsp.get_smeter_level() if smeter_level == None: break except: break - if smeter_level!=None: rxws.send(self, "MSG s={0}".format(smeter_level)) + if smeter_level!=None: + myclient.loopstat=31 + rxws.send(self, "MSG s={0}".format(smeter_level)) # ========= send bcastmsg ========= if myclient.bcastmsg!="": + myclient.loopstat=40 rxws.send(self,myclient.bcastmsg) myclient.bcastmsg="" # ========= process commands ========= while True: + myclient.loopstat=50 rdata=rxws.recv(self, False) if not rdata: break #try: @@ -512,25 +523,32 @@ class WebRXHandler(BaseHTTPRequestHandler): bpf_set=True new_bpf[1]=int(param_value) elif param_name == "offset_freq" and -cfg.samp_rate/2 <= float(param_value) <= cfg.samp_rate/2: + myclient.loopstat=510 dsp.set_offset_freq(int(param_value)) elif param_name == "squelch_level" and float(param_value) >= 0: + myclient.loopstat=520 dsp.set_squelch_level(float(param_value)) elif param_name=="mod": if (dsp.get_demodulator()!=param_value): + myclient.loopstat=530 if dsp_initialized: dsp.stop() dsp.set_demodulator(param_value) if dsp_initialized: dsp.start() elif param_name == "output_rate": if not dsp_initialized: + myclient.loopstat=540 dsp.set_output_rate(int(param_value)) + myclient.loopstat=541 dsp.set_samp_rate(cfg.samp_rate) elif param_name=="action" and param_value=="start": if not dsp_initialized: + myclient.loopstat=550 dsp.start() dsp_initialized=True else: print "[openwebrx-httpd:ws] invalid parameter" if bpf_set: + myclient.loopstat=560 dsp.set_bpf(*new_bpf) #code.interact(local=locals()) except: @@ -561,6 +579,7 @@ class WebRXHandler(BaseHTTPRequestHandler): traceback.print_tb(exc_traceback) finally: cmr() + myclient.loopstat=1000 return elif self.path in ("/status", "/status/"): #self.send_header('Content-type','text/plain')