Modbus-Arduino
Modbus library for Arduino
Modbus

Modbus base class. More...

#include <Modbus.h>

Collaboration diagram for Modbus:

Public Member Functions

 Modbus ()
 Default constructor.
 
void addHreg (word offset, word value=0)
 Add a holding register to the list. More...
 
bool setHreg (word offset, word value)
 Change the value of a holding register This value will be returned when bus read, the master can also modify it. More...
 
word hreg (word offset)
 Return the value of a holding register. More...
 
bool setHregBounds (word offset, word min, word max)
 Sets the bounds of a holding register. More...
 
bool hregOutOfBounds (word offset, word value)
 Checks if the value is outside the bounds of a holging register. More...
 
bool Hreg (word offset, word value)
 Change the value of a holding register This value will be returned when bus read, the master can also modify it. More...
 
word Hreg (word offset)
 Return the value of a holding register. More...
 
void setDebug (Print &print)
 Enable debug mode.
 
bool isDebug ()
 Returns true if debug mode is enabled.
 
void debug (const char *msg)
 Print a debug message, only if debug mode is enabled. More...
 
void addCoil (word offset, bool value=false)
 Add a coil. More...
 
void addIsts (word offset, bool value=false)
 Add a discrete input. More...
 
void addIreg (word offset, word value=0)
 Add a input register. More...
 
bool setCoil (word offset, bool value)
 Change the value of a coil This value will be returned when bus read, the master can also modify it. More...
 
bool setIsts (word offset, bool value)
 Change the value of a discrete input This value will be returned when bus read,. More...
 
bool setIreg (word offset, word value)
 Change the value of an input register This value will be returned when bus read. More...
 
bool coil (word offset)
 Return the value of a coil. More...
 
bool ists (word offset)
 Return the value of a discrete input. More...
 
word ireg (word offset)
 Return the value of an input register. More...
 
bool Coil (word offset, bool value)
 Change the value of a coil This value will be returned when bus read, the master can also modify it. More...
 
bool Ists (word offset, bool value)
 Change the value of a discrete input This value will be returned when bus read,. More...
 
bool Ireg (word offset, word value)
 Change the value of an input register This value will be returned when bus read. More...
 
bool Coil (word offset)
 Return the value of a coil. More...
 
bool Ists (word offset)
 Return the value of a discrete input. More...
 
word Ireg (word offset)
 Return the value of an input register. More...
 
int setAdditionalServerData (const char data[])
 Sets additional Data for Report Server ID function. More...
 

Detailed Description

Modbus base class.

Definition at line 65 of file Modbus.h.

Member Function Documentation

◆ addCoil()

void Modbus::addCoil ( word  offset,
bool  value = false 
)
inline

Add a coil.

Parameters
offsetcoil offset (PDU addressing: 0-9999)
valuedefault value

Definition at line 217 of file Modbus.h.

◆ addHreg()

void Modbus::addHreg ( word  offset,
word  value = 0 
)
inline

Add a holding register to the list.

Parameters
offsetregister offset (PDU addressing: 0-9999)
valuedefault value

Definition at line 121 of file Modbus.h.

◆ addIreg()

void Modbus::addIreg ( word  offset,
word  value = 0 
)
inline

Add a input register.

Parameters
offsetregister offset (PDU addressing: 0-9999)
valuedefault value

Definition at line 233 of file Modbus.h.

◆ addIsts()

void Modbus::addIsts ( word  offset,
bool  value = false 
)
inline

Add a discrete input.

Parameters
offsetinput offset (PDU addressing: 0-9999)
valuedefault value

Definition at line 225 of file Modbus.h.

◆ coil()

bool Modbus::coil ( word  offset)
inline

Return the value of a coil.

Parameters
offsetregister offset (PDU addressing: 0-9999)
Returns
coil value

Definition at line 271 of file Modbus.h.

Referenced by Coil().

◆ Coil() [1/2]

bool Modbus::Coil ( word  offset)
inline

Return the value of a coil.

Deprecated:
removed in next major release, use coil() instead.
Parameters
offsetregister offset (PDU addressing: 0-9999)
Returns
coil value

Definition at line 329 of file Modbus.h.

References coil().

Here is the call graph for this function:

◆ Coil() [2/2]

bool Modbus::Coil ( word  offset,
bool  value 
)
inline

Change the value of a coil This value will be returned when bus read, the master can also modify it.

Deprecated:
removed in next major release, use setCoil() instead.
Parameters
offsetregister offset (PDU addressing: 0-9999)
valuenew value
Returns
true, false if coil not found.

Definition at line 298 of file Modbus.h.

References setCoil().

Here is the call graph for this function:

◆ debug()

void Modbus::debug ( const char *  msg)
inline

Print a debug message, only if debug mode is enabled.

Parameters
msgmessage to print

Definition at line 204 of file Modbus.h.

◆ hreg()

word Modbus::hreg ( word  offset)
inline

Return the value of a holding register.

Parameters
offsetregister offset (PDU addressing: 0-9999)
Returns
register value

Definition at line 139 of file Modbus.h.

Referenced by Hreg().

◆ Hreg() [1/2]

word Modbus::Hreg ( word  offset)
inline

Return the value of a holding register.

Deprecated:
removed in next major release, use hreg() instead.
Parameters
offsetregister offset (PDU addressing: 0-9999)
Returns
register value

Definition at line 181 of file Modbus.h.

References hreg().

Here is the call graph for this function:

◆ Hreg() [2/2]

bool Modbus::Hreg ( word  offset,
word  value 
)
inline

Change the value of a holding register This value will be returned when bus read, the master can also modify it.

Deprecated:
removed in next major release, use setHreg() instead.
Parameters
offsetregister offset (PDU addressing: 0-9999)
valuenew value
Returns
true, false if register not found.

Definition at line 172 of file Modbus.h.

References setHreg().

Here is the call graph for this function:

◆ hregOutOfBounds()

bool Modbus::hregOutOfBounds ( word  offset,
word  value 
)
inline

Checks if the value is outside the bounds of a holging register.

Parameters
offsetregister offset (PDU addressing: 0-9999)
valuevalue to check
Returns
true if the value is outside the bounds, false otherwise

Definition at line 160 of file Modbus.h.

◆ ireg()

word Modbus::ireg ( word  offset)
inline

Return the value of an input register.

Parameters
offsetregister offset (PDU addressing: 0-9999)
Returns
register value

Definition at line 287 of file Modbus.h.

Referenced by Ireg().

◆ Ireg() [1/2]

word Modbus::Ireg ( word  offset)
inline

Return the value of an input register.

Deprecated:
removed in next major release, use ireg() instead.
Parameters
offsetregister offset (PDU addressing: 0-9999)
Returns
register value

Definition at line 347 of file Modbus.h.

References ireg().

Here is the call graph for this function:

◆ Ireg() [2/2]

bool Modbus::Ireg ( word  offset,
word  value 
)
inline

Change the value of an input register This value will be returned when bus read.

Deprecated:
removed in next major release, use setIreg() instead.
Parameters
offsetregister offset (PDU addressing: 0-9999)
valuenew value
Returns
true, false if register not found.

Definition at line 320 of file Modbus.h.

References setIreg().

Here is the call graph for this function:

◆ ists()

bool Modbus::ists ( word  offset)
inline

Return the value of a discrete input.

Parameters
offsetinput offset (PDU addressing: 0-9999)
Returns
input value

Definition at line 279 of file Modbus.h.

Referenced by Ists().

◆ Ists() [1/2]

bool Modbus::Ists ( word  offset)
inline

Return the value of a discrete input.

Deprecated:
removed in next major release, use ists() instead.
Parameters
offsetinput offset (PDU addressing: 0-9999)
Returns
input value

Definition at line 338 of file Modbus.h.

References ists().

Here is the call graph for this function:

◆ Ists() [2/2]

bool Modbus::Ists ( word  offset,
bool  value 
)
inline

Change the value of a discrete input This value will be returned when bus read,.

Deprecated:
removed in next major release, use setIsts() instead.
Parameters
offsetinput offset (PDU addressing: 0-9999)
valuenew value
Returns
true, false if input not found.

Definition at line 309 of file Modbus.h.

References setIsts().

Here is the call graph for this function:

◆ setAdditionalServerData()

int Modbus::setAdditionalServerData ( const char  data[])

Sets additional Data for Report Server ID function.

Parameters
datadata string
Returns
the number of chars gets from data (249 max)

◆ setCoil()

bool Modbus::setCoil ( word  offset,
bool  value 
)
inline

Change the value of a coil This value will be returned when bus read, the master can also modify it.

Parameters
offsetregister offset (PDU addressing: 0-9999)
valuenew value
Returns
true, false if coil not found.

Definition at line 243 of file Modbus.h.

Referenced by Coil().

◆ setHreg()

bool Modbus::setHreg ( word  offset,
word  value 
)
inline

Change the value of a holding register This value will be returned when bus read, the master can also modify it.

Parameters
offsetregister offset (PDU addressing: 0-9999)
valuenew value
Returns
true, false if register not found.

Definition at line 131 of file Modbus.h.

Referenced by Hreg().

◆ setHregBounds()

bool Modbus::setHregBounds ( word  offset,
word  min,
word  max 
)
inline

Sets the bounds of a holding register.

Parameters
offsetregister offset (PDU addressing: 0-9999)
minmin value
maxmax value
Returns
true, false if register not found.

Definition at line 150 of file Modbus.h.

◆ setIreg()

bool Modbus::setIreg ( word  offset,
word  value 
)
inline

Change the value of an input register This value will be returned when bus read.

Parameters
offsetregister offset (PDU addressing: 0-9999)
valuenew value
Returns
true, false if register not found.

Definition at line 263 of file Modbus.h.

Referenced by Ireg().

◆ setIsts()

bool Modbus::setIsts ( word  offset,
bool  value 
)
inline

Change the value of a discrete input This value will be returned when bus read,.

Parameters
offsetinput offset (PDU addressing: 0-9999)
valuenew value
Returns
true, false if input not found.

Definition at line 253 of file Modbus.h.

Referenced by Ists().