def uart_recv_header(serial): cnt=0 while True: data=serial.port.read() if data == b'\xff': data_next=serial.port.read() if data_next == b'\xff': cnt += 1 data_lens=serial.port.read(2) data_audio=serial.port.read(2) count=len(data_audio)/2 var=struct.unpack('h'*int(count),data_audio) global db_val db_val = float(var[0]/100) print(float(var[0]/100))
2.噪声数据实时显示更新:
def update_data(): db_ay.pop(0) db_ay.append(db_val) print("timer is occured is:",db_val) dpg.set_value('series_tag', [time_ax, db_ay]) dpg.set_item_label('series_tag', "nosie val:"+str(db_val)+":db")