使用pcomm庫sio_cnt_irq(port,CntIrq,1)的函數相關疑問

 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.

  

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章