尽量在一个单独的线程中运行
stim_thread = threading.Thread(target=rece_stim_data,args=(stim_serial_com,))
stim_thread.start()
""" 将刺激器数据存储到文件中
:param com
:return: 返回文件存储路径
"""
thread_flag = 1
def rece_stim_data(com):
global thread_flag
print("stim log file name:" + "controller"+ filename)
if com == None:
return
stim_serial = serial.Serial(com, 115200, timeout = 1)
f_path = output_dir +"/stim"+ filename
with open(f_path, "a", encoding='utf-8') as f:
while thread_flag:
data = stim_serial.readline().decode("utf-8")
if len(data) != 0:
f.write(data)
stim_serial.close()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)