[Modbus]
説明
Reads the value of the private array readData in the ModbusMasterNode class.
readData is the array stored after reading back to the Slave device registers using the Read function code.
構文
node1.getResponseBuffer(index, mode)
媒介変数
node1
: ModbusMasterNode object.index
: index value of the readData array.mode
: mode of reading data from readData array, its citation is MODBUS_DATAMODE_BIT or MODBUS_DATAMODE_UINT16. If no citation is given it will be MODBUS_DATAMODE_UINT16 by default.
戻り値
int: The value taken from the readData array, or 0xFFFF if it is wrong.
例
#include <Modbus86.h> ModbusMaster bus1; ModbusMasterNode node1; uint8_t result; uint32_t receiveData; void setup() { while(!Serial); Serial1.begin(115200); bus1.begin(MODBUS_RTU, Serial1); node1.attach(16, bus1); result = node1.readCoils(5, 2); if (result != MODBUS_SUCCESS) { Serial.print("readCoils => ErrorCode: "); Serial.println(result); } else { Serial.print("From Coil Status receiveData: "); receiveData = node1.getResponseBuffer(0) | (node1.getResponseBuffer(1) << 16); Serial.println(receiveData); } } void loop() {}
See Also
- clearResponseBuffer()
- readCoils()
- readDiscreteInputs()
- readHoldingRegisters()
- readInputRegisters()
- readWriteMultipleRegisters()
Libraries Reference Home
86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。