More debug information (loopstat)
This commit is contained in:
		
							
								
								
									
										23
									
								
								openwebrx.py
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								openwebrx.py
									
									
									
									
									
								
							| @@ -354,7 +354,7 @@ def cleanup_clients(end_all=False): | |||||||
| def generate_client_id(ip): | def generate_client_id(ip): | ||||||
| 	#add a client | 	#add a client | ||||||
| 	global clients | 	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.id=md5.md5(str(random.random())).hexdigest() | ||||||
| 	new_client.gen_time=time.time() | 	new_client.gen_time=time.time() | ||||||
| 	new_client.ws_started=False # to check whether client has ever tried to open the websocket | 	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))+")") | 					access_log("Started streaming to client: "+self.client_address[0]+"#"+myclient.id+" (users now: "+str(len(clients))+")") | ||||||
|  |  | ||||||
|  | 					myclient.loopstat=0 | ||||||
|  |  | ||||||
| 					while True: | 					while True: | ||||||
| 						if myclient.closed[0]: | 						if myclient.closed[0]: | ||||||
| 							print "[openwebrx-httpd:ws] client closed by other thread" | 							print "[openwebrx-httpd:ws] client closed by other thread" | ||||||
| @@ -466,34 +468,43 @@ class WebRXHandler(BaseHTTPRequestHandler): | |||||||
|  |  | ||||||
| 						# ========= send audio ========= | 						# ========= send audio ========= | ||||||
| 						if dsp_initialized: | 						if dsp_initialized: | ||||||
|  | 							myclient.loopstat=10 | ||||||
| 							temp_audio_data=dsp.read(256) | 							temp_audio_data=dsp.read(256) | ||||||
|  | 							myclient.loopstat=11 | ||||||
| 							rxws.send(self, temp_audio_data, "AUD ") | 							rxws.send(self, temp_audio_data, "AUD ") | ||||||
|  |  | ||||||
| 						# ========= send spectrum ========= | 						# ========= send spectrum ========= | ||||||
| 						while not myclient.spectrum_queue.empty(): | 						while not myclient.spectrum_queue.empty(): | ||||||
|  | 							myclient.loopstat=20 | ||||||
| 							spectrum_data=myclient.spectrum_queue.get() | 							spectrum_data=myclient.spectrum_queue.get() | ||||||
| 							#spectrum_data_mid=len(spectrum_data[0])/2 | 							#spectrum_data_mid=len(spectrum_data[0])/2 | ||||||
| 							#rxws.send(self, spectrum_data[0][spectrum_data_mid:]+spectrum_data[0][:spectrum_data_mid], "FFT ") | 							#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) | 							# (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 ") | 							rxws.send(self, spectrum_data[0],"FFT ") | ||||||
|  |  | ||||||
| 						# ========= send smeter_level ========= | 						# ========= send smeter_level ========= | ||||||
| 						smeter_level=None | 						smeter_level=None | ||||||
| 						while True: | 						while True: | ||||||
| 							try: | 							try: | ||||||
|  | 								myclient.loopstat=30 | ||||||
| 								smeter_level=dsp.get_smeter_level() | 								smeter_level=dsp.get_smeter_level() | ||||||
| 								if smeter_level == None: break | 								if smeter_level == None: break | ||||||
| 							except: | 							except: | ||||||
| 								break | 								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 ========= | 						# ========= send bcastmsg ========= | ||||||
| 						if myclient.bcastmsg!="": | 						if myclient.bcastmsg!="": | ||||||
|  | 							myclient.loopstat=40 | ||||||
| 							rxws.send(self,myclient.bcastmsg) | 							rxws.send(self,myclient.bcastmsg) | ||||||
| 							myclient.bcastmsg="" | 							myclient.bcastmsg="" | ||||||
|  |  | ||||||
| 						# ========= process commands ========= | 						# ========= process commands ========= | ||||||
| 						while True: | 						while True: | ||||||
|  | 							myclient.loopstat=50 | ||||||
| 							rdata=rxws.recv(self, False) | 							rdata=rxws.recv(self, False) | ||||||
| 							if not rdata: break | 							if not rdata: break | ||||||
| 							#try: | 							#try: | ||||||
| @@ -512,25 +523,32 @@ class WebRXHandler(BaseHTTPRequestHandler): | |||||||
| 										bpf_set=True | 										bpf_set=True | ||||||
| 										new_bpf[1]=int(param_value) | 										new_bpf[1]=int(param_value) | ||||||
| 									elif param_name == "offset_freq" and -cfg.samp_rate/2 <= float(param_value) <= cfg.samp_rate/2: | 									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)) | 										dsp.set_offset_freq(int(param_value)) | ||||||
| 									elif param_name == "squelch_level" and float(param_value) >= 0: | 									elif param_name == "squelch_level" and float(param_value) >= 0: | ||||||
|  | 										myclient.loopstat=520 | ||||||
| 										dsp.set_squelch_level(float(param_value)) | 										dsp.set_squelch_level(float(param_value)) | ||||||
| 									elif param_name=="mod": | 									elif param_name=="mod": | ||||||
| 										if (dsp.get_demodulator()!=param_value): | 										if (dsp.get_demodulator()!=param_value): | ||||||
|  | 											myclient.loopstat=530 | ||||||
| 											if dsp_initialized: dsp.stop() | 											if dsp_initialized: dsp.stop() | ||||||
| 											dsp.set_demodulator(param_value) | 											dsp.set_demodulator(param_value) | ||||||
| 											if dsp_initialized: dsp.start() | 											if dsp_initialized: dsp.start() | ||||||
| 									elif param_name == "output_rate": | 									elif param_name == "output_rate": | ||||||
| 										if not dsp_initialized: | 										if not dsp_initialized: | ||||||
|  | 											myclient.loopstat=540 | ||||||
| 											dsp.set_output_rate(int(param_value)) | 											dsp.set_output_rate(int(param_value)) | ||||||
|  | 											myclient.loopstat=541 | ||||||
| 											dsp.set_samp_rate(cfg.samp_rate) | 											dsp.set_samp_rate(cfg.samp_rate) | ||||||
| 									elif param_name=="action" and param_value=="start": | 									elif param_name=="action" and param_value=="start": | ||||||
| 										if not dsp_initialized: | 										if not dsp_initialized: | ||||||
|  | 											myclient.loopstat=550 | ||||||
| 											dsp.start() | 											dsp.start() | ||||||
| 											dsp_initialized=True | 											dsp_initialized=True | ||||||
| 									else: | 									else: | ||||||
| 										print "[openwebrx-httpd:ws] invalid parameter" | 										print "[openwebrx-httpd:ws] invalid parameter" | ||||||
| 								if bpf_set: | 								if bpf_set: | ||||||
|  | 									myclient.loopstat=560 | ||||||
| 									dsp.set_bpf(*new_bpf) | 									dsp.set_bpf(*new_bpf) | ||||||
| 								#code.interact(local=locals()) | 								#code.interact(local=locals()) | ||||||
| 				except: | 				except: | ||||||
| @@ -561,6 +579,7 @@ class WebRXHandler(BaseHTTPRequestHandler): | |||||||
| 					traceback.print_tb(exc_traceback) | 					traceback.print_tb(exc_traceback) | ||||||
| 				finally: | 				finally: | ||||||
| 					cmr() | 					cmr() | ||||||
|  | 				myclient.loopstat=1000 | ||||||
| 				return | 				return | ||||||
| 			elif self.path in ("/status", "/status/"): | 			elif self.path in ("/status", "/status/"): | ||||||
| 				#self.send_header('Content-type','text/plain') | 				#self.send_header('Content-type','text/plain') | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ha7ilm
					ha7ilm