Modbus Master and Slave for Arduino  1.2
Arduino library for implementing a Modbus Master or Slave through Serial port
Classes | Macros | Enumerations | Variables
ModbusRtu.h File Reference

Go to the source code of this file.

Classes

struct  modbus_t
 Master query structure: This includes all the necessary fields to make the Master generate a Modbus query. A Master may keep several of these structures and send them cyclically or use them according to program needs. More...
 
class  Modbus
 Arduino class library for communicating with Modbus devices over USB/RS232/485 (via RTU protocol). More...
 

Macros

#define T35   5
 
#define MAX_BUFFER   64
 maximum size for the communication buffer in bytes More...
 

Enumerations

enum  { RESPONSE_SIZE = 6, EXCEPTION_SIZE = 3, CHECKSUM_SIZE = 2 }
 
enum  MESSAGE {
  ID = 0, FUNC, ADD_HI, ADD_LO,
  NB_HI, NB_LO, BYTE_CNT
}
 Indexes to telegram frame positions. More...
 
enum  MB_FC {
  MB_FC_NONE = 0, MB_FC_READ_COILS = 1, MB_FC_READ_DISCRETE_INPUT = 2, MB_FC_READ_REGISTERS = 3,
  MB_FC_READ_INPUT_REGISTER = 4, MB_FC_WRITE_COIL = 5, MB_FC_WRITE_REGISTER = 6, MB_FC_WRITE_MULTIPLE_COILS = 15,
  MB_FC_WRITE_MULTIPLE_REGISTERS = 16
}
 Modbus function codes summary. These are the implement function codes either for Master or for Slave. More...
 
enum  COM_STATES { COM_IDLE = 0, COM_WAITING = 1 }
 
enum  ERR_LIST {
  ERR_NOT_MASTER = -1, ERR_POLLING = -2, ERR_BUFF_OVERFLOW = -3, ERR_BAD_CRC = -4,
  ERR_EXCEPTION = -5
}
 
enum  {
  NO_REPLY = 255, EXC_FUNC_CODE = 1, EXC_ADDR_RANGE = 2, EXC_REGS_QUANT = 3,
  EXC_EXECUTE = 4
}
 

Variables

const unsigned char fctsupported []
 

Detailed Description

Version
1.2
Date
2014.09.09
Author
Samuel Marco i Armengol samma.nosp@m.rcoa.nosp@m.rmeng.nosp@m.ol@g.nosp@m.mail..nosp@m.com

Arduino library for communicating with Modbus devices over RS232/USB/485 via RTU protocol.

Further information: http://modbus.org/ http://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Definition in file ModbusRtu.h.

Macro Definition Documentation

#define MAX_BUFFER   64

maximum size for the communication buffer in bytes

Definition at line 133 of file ModbusRtu.h.

#define T35   5

Definition at line 132 of file ModbusRtu.h.

Enumeration Type Documentation

anonymous enum
Enumerator
RESPONSE_SIZE 
EXCEPTION_SIZE 
CHECKSUM_SIZE 

Definition at line 57 of file ModbusRtu.h.

anonymous enum
Enumerator
NO_REPLY 
EXC_FUNC_CODE 
EXC_ADDR_RANGE 
EXC_REGS_QUANT 
EXC_EXECUTE 

Definition at line 113 of file ModbusRtu.h.

enum COM_STATES
Enumerator
COM_IDLE 
COM_WAITING 

Definition at line 99 of file ModbusRtu.h.

enum ERR_LIST
Enumerator
ERR_NOT_MASTER 
ERR_POLLING 
ERR_BUFF_OVERFLOW 
ERR_BAD_CRC 
ERR_EXCEPTION 

Definition at line 105 of file ModbusRtu.h.

enum MB_FC

Modbus function codes summary. These are the implement function codes either for Master or for Slave.

See Also
also fctsupported
also modbus_t
Enumerator
MB_FC_NONE 

null operator

MB_FC_READ_COILS 

FCT=1 -> read coils or digital outputs

MB_FC_READ_DISCRETE_INPUT 

FCT=2 -> read digital inputs

MB_FC_READ_REGISTERS 

FCT=3 -> read registers or analog outputs

MB_FC_READ_INPUT_REGISTER 

FCT=4 -> read analog inputs

MB_FC_WRITE_COIL 

FCT=5 -> write single coil or output

MB_FC_WRITE_REGISTER 

FCT=6 -> write single register

MB_FC_WRITE_MULTIPLE_COILS 

FCT=15 -> write multiple coils or outputs

MB_FC_WRITE_MULTIPLE_REGISTERS 

FCT=16 -> write multiple registers

Definition at line 87 of file ModbusRtu.h.

enum MESSAGE

Indexes to telegram frame positions.

Enumerator
ID 

ID field.

FUNC 

Function code position.

ADD_HI 

Address high byte.

ADD_LO 

Address low byte.

NB_HI 

Number of coils or registers high byte.

NB_LO 

Number of coils or registers low byte.

BYTE_CNT 

byte counter

Definition at line 68 of file ModbusRtu.h.

Variable Documentation

const unsigned char fctsupported[]