|
@@ -72,15 +72,15 @@ class SurveillanceRadar:
|
|
|
return signal.astype(np.complex64), amplitude
|
|
|
def tx_worker(self):
|
|
|
"""发送线程函数"""
|
|
|
- try:
|
|
|
- metadata = uhd.types.TXMetadata()
|
|
|
- metadata.start_of_burst = True
|
|
|
- metadata.end_of_burst = False
|
|
|
- metadata.has_time_spec = False
|
|
|
+ metadata = uhd.types.TXMetadata()
|
|
|
+ metadata.start_of_burst = True
|
|
|
+ metadata.end_of_burst = False
|
|
|
+ metadata.has_time_spec = False
|
|
|
|
|
|
- print("发送线程已启动")
|
|
|
+ print("发送线程已启动")
|
|
|
|
|
|
- while not self.stop_event.is_set():
|
|
|
+ while not self.stop_event.is_set():
|
|
|
+ try:
|
|
|
# 生成随机信号
|
|
|
signal, amplitude = self.generate_signal()
|
|
|
self.tx_signal = signal
|
|
@@ -89,20 +89,21 @@ class SurveillanceRadar:
|
|
|
# print("samples:", samples)
|
|
|
# 发送信号
|
|
|
self.tx_stream.send(signal, metadata)
|
|
|
- # 将100个信号依次队列
|
|
|
+ print("数据已发送")
|
|
|
+ # 将100个信号依次队列
|
|
|
#如果队列已满,则去对头元素
|
|
|
if self.tx_buffer.full():
|
|
|
self.tx_buffer.get()
|
|
|
self.tx_buffer.put(samples.copy())
|
|
|
# 控制发送频率
|
|
|
time.sleep(0.05)
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- # self.stop_event.set()
|
|
|
- # metadata.end_of_burst = True
|
|
|
- # self.tx_stream.send(np.zeros((1,), dtype=np.complex64), metadata)
|
|
|
- # raise Exception(f"发送线程出错: {e}")
|
|
|
- print(f"发送线程出错: {e}")
|
|
|
+ except Exception as e:
|
|
|
+ # self.stop_event.set()
|
|
|
+ # metadata.end_of_burst = True
|
|
|
+ # self.tx_stream.send(np.zeros((1,), dtype=np.complex64), metadata)
|
|
|
+ # raise Exception(f"发送线程出错: {e}")
|
|
|
+ print(f"发送线程出错: {e}")
|
|
|
+
|
|
|
|
|
|
|
|
|
def rx_worker(self):
|
|
@@ -116,7 +117,7 @@ class SurveillanceRadar:
|
|
|
buff = np.zeros((self.samps_per_packet,), dtype=np.complex64)
|
|
|
while not self.stop_event.is_set():
|
|
|
try:
|
|
|
- num_rx = self.rx_stream.recv(buff, metadata,timeout=10)
|
|
|
+ num_rx = self.rx_stream.recv(buff, metadata)
|
|
|
if metadata.error_code != uhd.types.RXMetadataErrorCode.none:
|
|
|
print(f"接收错误: {metadata.error_code}")
|
|
|
continue
|