This commit is contained in:
MobKBK
2026-05-26 03:37:33 +08:00
parent 8531c4dc9e
commit 62cae27c54
6 changed files with 35 additions and 32 deletions

View File

@@ -117,7 +117,7 @@ def run_live(port, baud, save_csv=None):
'pos_x', 'pos_y', 'pos_z'])
print(f"打开串口 {port} @ {baud} baud ...")
ser = serial.Serial(port, baud, timeout=1)
ser = serial.Serial(port, baud, timeout=0.01) # 短超时, 避免 read(1) 阻塞
# 静止标定
accel_bias, gyro_bias = calibrate(ser)
@@ -135,6 +135,7 @@ def run_live(port, baud, save_csv=None):
while plt.fignum_exists(viewer.fig.number):
frame = read_frame(ser)
if frame is None:
time.sleep(0.001) # 无数据时短暂休眠, 避免忙等
continue
ts = frame['timestamp_ms']