Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zfz1120 opened this issue May 25, 2022 · 3 comments
Closed

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

zfz1120 opened this issue May 25, 2022 · 3 comments

Comments

@zfz1120
Copy link

zfz1120 commented May 25, 2022

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

@Neutree
Copy link
Owner

Neutree commented May 25, 2022

应该和 #52 问题一样

@zfz1120
Copy link
Author

zfz1120 commented May 30, 2022

应该和 #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
Copy link
Owner

Neutree commented Aug 21, 2022

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

@Neutree Neutree closed this as completed Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants