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

颜色 #52

Closed
QingHuanFerry opened this issue Apr 14, 2022 · 7 comments
Closed

颜色 #52

QingHuanFerry opened this issue Apr 14, 2022 · 7 comments
Labels

Comments

@QingHuanFerry
Copy link

image
有时候不能够添加颜色

@Neutree Neutree added the bug label Apr 14, 2022
@Neutree
Copy link
Owner

Neutree commented Apr 14, 2022

应该是包被分割了,目前代码里面是从每个包检测颜色控制符,控制符被分割成两个包了,所以可以保证发送颜色控制符号的时间间隔不要太长来避免,有时间我优化下这个问题

@QingHuanFerry
Copy link
Author

你好,这边发现一个其他的问题,有时候串口的数据接收会接收不完整,
1650425809(1)
1650425790

@Neutree
Copy link
Owner

Neutree commented Apr 20, 2022

丢数据应该不太可能 这部分功能应该挺可靠的,能用什么方法复现吗

@QingHuanFerry
Copy link
Author

对的,我弄错了,应该不是接收不到,而是没有显示出来,就是这个数据明明是一包一包发的,但是数据会连着下一包一起显示出来

@Neutree
Copy link
Owner

Neutree commented Apr 20, 2022

接收代码在这里,

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''
, 可能还有可以优化缓冲区的处理

@Neutree
Copy link
Owner

Neutree commented Aug 21, 2022

尝试修复了 fe37bf8 , 可以拉取最新代码试试

@Neutree
Copy link
Owner

Neutree commented Nov 18, 2023

先关闭了,有问题再打开或者新建issue

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

No branches or pull requests

2 participants