Modbus Master and Slave for Arduino  1.2
Arduino library for implementing a Modbus Master or Slave through Serial port
Functions
Modbus Object Management

Functions

boolean Modbus::getTimeOutState ()
 get communication watch-dog timer state More...
 
int8_t Modbus::query (modbus_t telegram)
 only for master More...
 
int8_t Modbus::poll ()
 cyclic poll for master More...
 
int8_t Modbus::poll (uint16_t *regs, uint8_t u8size)
 cyclic poll for slave More...
 

Detailed Description

Function Documentation

boolean Modbus::getTimeOutState ( )

get communication watch-dog timer state

Return communication Watchdog state. It could be usefull to reset outputs if the watchdog is fired.

Returns
TRUE if millis() > u32timeOut

Definition at line 350 of file ModbusRtu.h.

int8_t Modbus::poll ( )

cyclic poll for master

*** Only for Modbus Master *** This method checks if there is any incoming answer if pending. If there is no answer, it would change Master state to COM_IDLE. This method must be called only at loop section. Avoid any delay() function.

Any incoming data would be redirected to au16regs pointer, as defined in its modbus_t query telegram.

nothing

Returns
errors counter

Definition at line 513 of file ModbusRtu.h.

int8_t Modbus::poll ( uint16_t *  regs,
uint8_t  u8size 
)

cyclic poll for slave

*** Only for Modbus Slave *** This method checks if there is any incoming query Afterwards, it would shoot a validation routine plus a register query Avoid any delay() function !!!! After a successful frame between the Master and the Slave, the time-out timer is reset.

Parameters
*regsregister table for communication exchange
u8sizesize of the register table
Returns
0 if no query, 1..4 if communication error, >4 if correct query processed

Definition at line 588 of file ModbusRtu.h.

int8_t Modbus::query ( modbus_t  telegram)

only for master

*** Only Modbus Master *** Generate a query to an slave with a modbus_t telegram structure The Master must be in COM_IDLE mode. After it, its state would be COM_WAITING. This method has to be called only in loop() section.

See Also
modbus_t
Parameters
modbus_tmodbus telegram structure (id, fct, ...)
Todo:
finish function 15

Definition at line 425 of file ModbusRtu.h.