使用pcomm库sio_cnt_irq(port,CntIrq,1)的函数相关疑问

来源:互联网 发布:医生用药app软件 编辑:程序博客网 时间:2024/06/05 22:51

 sio_cnt_irq(ComPort,CntIrq,1);不是每接收一个字节函数会触发一次回调函数, 而是说只要串口收到大于等于一个字节数的数据就会触发,但可以用这个函数sio_read的返回值判断是否已经收完本帧数据, 注意,数据帧的长度必须在协议里规定好,或者包含在数据帧中一起发到PC, 以供程序判断是否读完一帧数据, 然后继续接收下一帧数据, 这样,至于需要触发多少次中断回调函数都无关紧要了。

modbus子站程序中用到中断方式处理。查询资料才知道,要modus子程序的留言。
 

sio_read 

Note:

If the length of data in the driver's input buffer is less than the buffer defined for sioread(), all data in the driver's input buffer will be transferred to that of sio_read(). Otherwise, sio_read() reads specified length bytes from the driver's input buffer.

  

 

原创粉丝点击