Closed NanoPangBZ closed 5 months ago
描述bug 当read的数量大于ring_buf当前的数值是会有bug
重现步骤
//初始化 port1 = new CSerialPort; port1->init( "COM2" , 256000 ); port1->setOperateMode(AsynchronousOperate); port1->setReadBufferSize(1024); port1->setReadIntervalTimeout(0); port1->open();
//自己的额外的接收线程 static void port1_across_impl(void args) { uint8_t buf[1024]; int read_cnt; int write_cnt; int writed_cnt; while(1) { read_cnt = port1->readData( buf , 12 ); if( read_cnt != 0 ) { std::cout<<read_cnt<<std::endl; } } pthread_exit(NULL); }
//外围设备向port1发送"12341241234132421342314\r\n"之后便没有后续发送了,但是readData函数仍然返回12,断点查看 ibuffer.hpp中的read方法发现m_head一直在增长
运行环境信息:
感谢反馈 建议加Q群129518033沟通,这样效率更高
描述bug 当read的数量大于ring_buf当前的数值是会有bug
重现步骤
//初始化 port1 = new CSerialPort; port1->init( "COM2" , 256000 ); port1->setOperateMode(AsynchronousOperate); port1->setReadBufferSize(1024); port1->setReadIntervalTimeout(0); port1->open();
//自己的额外的接收线程 static void port1_across_impl(void args) { uint8_t buf[1024]; int read_cnt; int write_cnt; int writed_cnt; while(1) { read_cnt = port1->readData( buf , 12 ); if( read_cnt != 0 ) { std::cout<<read_cnt<<std::endl; } } pthread_exit(NULL); }
//外围设备向port1发送"12341241234132421342314\r\n"之后便没有后续发送了,但是readData函数仍然返回12,断点查看 ibuffer.hpp中的read方法发现m_head一直在增长
运行环境信息: