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

关于 设置读取通知触发最大字节数问题 #86

Open
yangwei1987 opened this issue May 11, 2024 · 3 comments
Open

关于 设置读取通知触发最大字节数问题 #86

yangwei1987 opened this issue May 11, 2024 · 3 comments

Comments

@yangwei1987
Copy link

描述bug
设置4096缓冲区,设置超时时间1ms,单次发送数据6280,实际只接收到4096数据,对缓冲区溢出未作保护;

重现步骤
设置4096缓冲区,设置超时时间1ms,单次发送数据6280

预期行为
设置读取通知触发最大字节数问题

截图
如果适用,请添加屏幕截图以帮助解释您的问题

运行环境信息:

  • 操作系统: [e.g. DeepIn 15.11 64bit/Win7 Ultimate 64bit]
  • 编译器:[e.g. QT 5.6.2 GCC 6.3.0/VS2013 update 5]
  • 版本号[e.g. 4.0.3.200429]

其他内容
在此处添加有关该问题的任何其他内容

@itas109
Copy link
Owner

itas109 commented May 11, 2024

目前的策略是缓冲区满了,直接覆盖。
即便是有最大字节数通知功能,也不能避免缓冲区被覆盖问题。
因此,建议根据实际业务调整缓冲区大小,最大 maxBufferSize = 1073741824;// 2^30

@itas109
Copy link
Owner

itas109 commented May 11, 2024

最大字节数通知功能 是一个比较好的建议,虽然不能完全避免缓冲区覆盖问题。
但也能一定程度上解决推送问题。
后续会增加该功能。

@yangwei1987
Copy link
Author

非常感谢您能接受提出的建议,目前我在void *CSerialPortUnixBase::commThreadMonitor(void *pParam)中做了轻微改动,但是使用不灵活,希望后续能增加配置超出后通知接口配置。
if(p_base->p_buffer->getUnusedLen()<2048){ p_base->p_readEvent->onReadEvent(p_base->getPortName(), p_base->p_buffer->getUsedLen()); }else{ p_base->p_timer->startOnce(readIntervalTimeoutMS, p_base->p_readEvent, &itas109::CSerialPortListener::onReadEvent, p_base->getPortName(), p_base->p_buffer->getUsedLen()); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants