[Modbus]
Description
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.
Syntax
node1.getResponseBuffer(index, mode)
Parameters
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.
Returns
int: The value taken from the readData array, or 0xFFFF if it is wrong.
Example
#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
The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.