Modbus TCP 0.1.0

Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ModbusTCP Class Reference

`#include <ModbusTCP.h>`

## Public Member Functions
| ModbusTCP ()
| ModbusTCP (uint8_t)
void | setUnitId (uint8_t)
void | setTransactionID (uint16_t)
void | setServerIPAddress (IPAddress)
void | idle (void(*)())
uint8_t | getResponseBufferLength ()
uint16_t | getResponseBuffer (uint8_t)
void | clearResponseBuffer ()
uint8_t | setTransmitBuffer (uint8_t, uint16_t)
void | clearTransmitBuffer ()
uint8_t | readCoils (uint16_t, uint16_t)
uint8_t | readDiscreteInputs (uint16_t, uint16_t)
uint8_t | readHoldingRegisters (uint16_t, uint16_t)
uint8_t | readInputRegisters (uint16_t, uint8_t)
uint8_t | writeSingleCoil (uint16_t, uint8_t)
uint8_t | writeSingleRegister (uint16_t, uint16_t)
uint8_t | writeMultipleCoils (uint16_t, uint16_t)
uint8_t | writeMultipleRegisters (uint16_t, uint16_t)
uint8_t | maskWriteRegister (uint16_t, uint16_t, uint16_t)
uint8_t | readWriteMultipleRegisters (uint16_t, uint16_t, uint16_t, uint16_t)

## Public Attributes
IPAddress | serverIP
UIPClient | ModbusClient
char | MBconnectionFlag = 0

## Static Public Attributes
static const uint8_t | MBIllegalFunction = 0x01
static const uint8_t | MBIllegalDataAddress = 0x02
static const uint8_t | MBIllegalDataValue = 0x03
static const uint8_t | MBServerConnectionTimeOut = 0x05
static const uint8_t | MBSuccess = 0x00
static const uint8_t | MBInvalidTransactionID = 0xE0
static const uint8_t | MBInvalidFunction = 0xE1
static const uint8_t | MBResponseTimedOut = 0xE2
static const uint8_t | MBInvalidUnitID = 0xE3
static const uint8_t | MBInvalidProtocol = 0xE4

## Detailed Description

Arduino class library for communicating with Modbus server over TCP/IP.

## Constructor & Destructor Documentation

## ◆ ModbusTCP() [1/2]

ModbusTCP::ModbusTCP | ( | void |  | ) |

Constructor.

## ◆ ModbusTCP() [2/2]

ModbusTCP::ModbusTCP | ( | uint8_t | u8MBUnitID | ) |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Constructor.

Creates class object using Modbus Unit ID. This is for unique identification of individual client by the server.

Parameters

  u8MBUnitID | Modbus Unit ID (1..255)

## Member Function Documentation

## ◆ idle()

void ModbusTCP::idle | ( | void(*)() | idle | ) |

Set idle time callback function (cooperative multitasking).

This function gets called in the idle time between transmission of data and response from Unit. Do not call functions that read from the serial buffer that is used by ModbusTCP. Use of i2c/TWI, 1-Wire, other serial ports, etc. is permitted within callback function.

See also
  ModbusTCP::ModbusMasterTransaction()

## ◆ setServerIPAddress()

void ModbusTCP::setServerIPAddress | ( | IPAddress | ipAddr | ) |

## ◆ setTransactionID()

void ModbusTCP::setTransactionID | ( | uint16_t | transactionID | ) |

## ◆ setUnitId()

void ModbusTCP::setUnitId | ( | uint8_t | u8MBUnitID | ) |

## Member Data Documentation

## ◆ MBconnectionFlag

char ModbusTCP::MBconnectionFlag = 0

## ◆ MBInvalidProtocol

const uint8_t ModbusTCP::MBInvalidProtocol = 0xE4
| static

## ◆ ModbusClient

UIPClient ModbusTCP::ModbusClient

## ◆ serverIP

IPAddress ModbusTCP::serverIP

The documentation for this class was generated from the following files:

- ModbusTCP.h
- ModbusTCP.cpp