底下內容從 Modbus通訊協定 V1.1b3 中,經我的理解及需求(僅 Modbus-RTU, RS485 的部份)記錄,可能會比較破碎凌亂,建議您可以閱讀原始文件。
- ADU : Application data unit.
- PDU : Protocol data unit.
※ ADU最大長度為 256 bytes.
※ PDU最大長度為 253 bytes. (ADU最大長度 減 1byte的位址 及 2bytes的CRC檢驗碼)
※ 3種PDU型式:
- Request PDU → function_code[1byte], request_data[n bytes]
- Response PDU → function_code[1byte], response_data[n bytes]
- Exception Response PDU → exception-function_code[1byte], request_data[1byte]
(exception-function_code = function_code + 0x80)
※ 位元組順序採用 big-Endian 方式,先傳高位元組,再傳低位元組。
※ 在PDU中,尋址範圍為 0 ~ 65535
※ 自定義的 function code 範圍為 65~72 以及 100 ~ 110
※ 檢測到通信錯誤(例如:奇偶校驗、LRC、CRC...)不返迴響應。
※ Exception code :
- 0x01 : Illegal function.
- 0x02 : Illegal data address.
- 0x03 : Illegal data value.
- 0x04 : Server device failure.
※ 設備 ID 範圍為 1 ~ 247, 0為廣播。
※ 主設備須有超時檢查。
文章標籤
全站熱搜