Neutree / COMTool

Cross platform communicate assistant(Serial/network/terminal tool)( 跨平台 串口调试助手 网络调试助手 终端工具 linux windows mac Raspberry Pi )支持插件和二次开发
https://neucrack.com/p/186
GNU Lesser General Public License v3.0
1.85k stars 338 forks source link

自动换行超时时间机制不对 #56

Closed zfz1120 closed 1 year ago

zfz1120 commented 2 years ago

经常出现连续数据帧被错误换行的情况。超时时间应该是前一个字节到下一个字节的间隔时间

Neutree commented 2 years ago

应该和 #52 问题一样

zfz1120 commented 2 years ago

应该和 #52 问题一样

 length = max(1, self.com.in_waiting) 
 data = self.com.read(length) 
 if data: 
     t = time.time() 
     if length == 1 and not buffer: # just start receive 
         buffer += data 
         continue 
     buffer += data 
 if buffer and (time.time() - t > 0.001): # no new data in 1ms 
     try: 
         self.onReceived(buffer) 
     except Exception as e: 
         print("-- error in onReceived callback:", e) 
     buffer = b'' 

if buffer and (time.time() - t > 0.001): # no new data in 1ms 老哥,这个0.001应该是从界面上设置的自动换行时间啊

Neutree commented 2 years ago

尝试修复了 fe37bf8a02fed6a4ed4c609204d61a323e46d569 , 可以试试是否符合预期