ja-jp_commands:reference:imodbusrtumaster
文書の過去の版を表示しています。
ImodbusRTUmaster()
ImodbusRTUmaster()は1つのMaster要求を直ちに実行します。
uint8_t ImodbusRTUmaster(HardwareSerial& serialPort, uint8_t slaveId, uint8_t functionCode, uint16_t address, uint16_t quantity, uint16_t* data, uint16_t timeoutMs = 100)
コマンド
| コマンド | 引数 | 戻り値 | 動作 |
|---|---|---|---|
ImodbusRTUmaster(serialPort, slaveId, functionCode, address, quantity, data, timeoutMs) | HardwareSerial& serialPort — RS-485に接続したSerialuint8_t slaveId — Slaveアドレスuint8_t functionCodeuint16_t addressuint16_t quantityuint16_t* datauint16_t timeoutMs = 100 | uint8_t | 1つのMaster要求を直ちに実行します。 |
使用例
uint16_t data[2]; uint8_t result = ImodbusRTUmaster( Serial2, 1, 3, 0, 2, data, 200);
注意事項
- SlaveまたはMasterの実行関数を
loop()で継続的に呼び出します。 - データ配列のサイズは要求quantity以上にしてください。
- 戻りコードのBUSYとIDLEを通信失敗として扱わないでください。
- Cnet/MC Protocolと
M、Dを共有する場合、最終サイズと初期化順序を統一します。ImodbusRTUMem()やICnetMem()を実行中に再呼び出ししないでください。 - メモリ割り当て関数は成功状態を返しません。サイズが0でない場合、
M、Dがnullptrでないことを確認してからユーザーコードでアクセスしてください。
ja-jp_commands/reference/imodbusrtumaster.1788785590.txt.gz · 最終更新: by 127.0.0.1
