SensorModbusMaster.h file

Contains the modbusMaster class declarations.

Classes

union leFrame
A frame for holding parts of a response. Define a little-endian frame as a union - that is a special class type that can hold only one of its non-static data members at a time.
class modbusMaster
The class for communicating with modbus devices.

Enums

enum endianness { littleEndian = 0, bigEndian }
The "endianness" of returned values.
enum pointerType { holdingRegister = 0, inputRegister, inputContacts, outputCoil }
The types of "pointers" to other modbus addresses.

Typedefs

using endianness = enum endianness
The "endianness" of returned values.
using pointerType = enum pointerType
The types of "pointers" to other modbus addresses.
using leFrame = union leFrame
A frame for holding parts of a response. Define a little-endian frame as a union - that is a special class type that can hold only one of its non-static data members at a time.

Defines

#define RESPONSE_BUFFER_SIZE = 256
The size of the response buffer for the modbus devices.
#define MODBUS_TIMEOUT = 500
The default time to wait for response after a command (in ms)
#define MODBUS_FRAME_TIMEOUT = 4
The default time to wait between characters within a frame (in ms)
#define BYTE_SIZE = 1
The size of a single byte in bytes.
#define UINT16_SIZE = 2
The size of an uint16_t in bytes.
#define INT16_SIZE = 2
The size of an int16_t in bytes.
#define UINT32_SIZE = 4
The size of an uint32_t in bytes.
#define INT32_SIZE = 4
The size of an int32_t in bytes.
#define FLOAT32_SIZE = 4
The size of a float32 in bytes.
#define TAI64_SIZE = 8
The size of a 64-bit timestamp in bytes.
#define TAI64N_SIZE = 12
The size of a 64-bit timestamp plus a 32-bit nanosecond in bytes.
#define TAI64NA_SIZE = 16
The size of a 64-bit timestamp plus a 32-bit nanosecond plus a 32-bit attosecond in bytes.
#define POINTER_SIZE = 2
The size of a pointer in bytes (when using Ardino system)

Enum documentation

enum endianness

The "endianness" of returned values.

Enumerators
littleEndian

little endian

bigEndian

big endian


enum pointerType

The types of "pointers" to other modbus addresses.

Sometimes values in registers are set as the address of a pointer to look at for the real value rather than being set as the values themselves. This pointer type tells you in what section of the memory map to look for the value being pointed to.

Enumerators
holdingRegister

pointer to a holding register

inputRegister

pointer to an input register

inputContacts

pointer to a input contact

outputCoil

pointer to a output coil


Typedef documentation

typedef enum pointerType pointerType

The types of "pointers" to other modbus addresses.

Sometimes values in registers are set as the address of a pointer to look at for the real value rather than being set as the values themselves. This pointer type tells you in what section of the memory map to look for the value being pointed to.


typedef union leFrame leFrame

A frame for holding parts of a response. Define a little-endian frame as a union - that is a special class type that can hold only one of its non-static data members at a time.

With avr-gcc (Arduino's compiler), integer and floating point variables are all physically stored in memory in little-endian byte order, so this union is all that is needed to translate modbus byte data into the other data forms.


Define documentation

#define RESPONSE_BUFFER_SIZE = 256

The size of the response buffer for the modbus devices.

This needs to be bigger than the largest response. Per the Specification and Implementation Guide for MODBUS over serial line, this value is 256 bytes. (This translates into a maximum of 125 registers to be read via Modbus/RTU and 123 by Modbus/TCP.)

If you know you will never make any modbus calls longer than this, decrease this number to save memory space.


#define MODBUS_FRAME_TIMEOUT = 4

The default time to wait between characters within a frame (in ms)

The modbus protocol defines that there can be no more than 1.5 characters of silence between characters in a frame and any space over 3.5 characters defines a new frame.