My Project
Classes | Typedefs | Enumerations | Variables
uuid::modbus Namespace Reference

Asynchronous Modbus library. More...

Classes

class  ExceptionStatusResponse
 Exception status response message. More...
 
class  RegisterDataResponse
 Register data response message. More...
 
class  RegisterRequest
 Request message for register functions. More...
 
class  RegisterWriteResponse
 Register write response message. More...
 
class  Request
 Request message. More...
 
class  Response
 Response message. More...
 
class  SerialClient
 Serial client used to process requests. More...
 

Typedefs

using frame_buffer_t = std::array< uint8_t, MAX_MESSAGE_SIZE+1 >
 

Enumerations

enum  DeviceAddressType : uint8_t { BROADCAST = 0, MIN_UNICAST = 1, MAX_UNICAST = 247 }
 Device address types. More...
 
enum  FunctionCode : uint8_t { READ_HOLDING_REGISTERS = 0x03, READ_INPUT_REGISTERS = 0x04, WRITE_SINGLE_REGISTER = 0x06, READ_EXCEPTION_STATUS = 0x07 }
 Function codes. More...
 
enum  ResponseStatus : uint8_t {
  QUEUED, TRANSMIT, WAITING, SUCCESS,
  EXCEPTION, FAILURE_INVALID, FAILURE_CRC, FAILURE_TIMEOUT,
  FAILURE_TOO_SHORT, FAILURE_TOO_LONG, FAILURE_ADDRESS, FAILURE_FUNCTION,
  FAILURE_LENGTH, FAILURE_UNEXPECTED
}
 Status of response messages. More...
 

Variables

const uuid::log::Logger logger {reinterpret_cast<const __FlashStringHelper *>(__pstr__loggername), uuid::log::Facility::DAEMON}
 
constexpr uint16_t MAX_MESSAGE_SIZE = 256
 
constexpr uint16_t MESSAGE_HEADER_SIZE = 2
 
constexpr uint16_t MESSAGE_CRC_SIZE = 2
 
constexpr uint32_t INTER_FRAME_TIMEOUT_MS = 5
 Timeout between frames (in milliseconds). More...
 
constexpr uint16_t DEFAULT_UNICAST_TIMEOUT_MS = 10000
 
constexpr uint16_t DEFAULT_BROADCAST_TIMEOUT_MS = 1000
 

Detailed Description

Asynchronous Modbus library.

Provides a client for communication using the Modbus protocol. This library is for single threaded applications and cannot be used from an interrupt context.

Typedef Documentation

◆ frame_buffer_t

using uuid::modbus::frame_buffer_t = typedef std::array<uint8_t, MAX_MESSAGE_SIZE + 1>

Buffer for receiving frames.

Since
0.1.0

Definition at line 67 of file modbus.h.

Enumeration Type Documentation

◆ DeviceAddressType

Device address types.

All other values are reserved.

Since
0.1.0
Enumerator
BROADCAST 

Broadcast device address.

Since
0.1.0
MIN_UNICAST 

Minimum device address.

Since
0.1.0
MAX_UNICAST 

Maximum device address.

Since
0.1.0

Definition at line 76 of file modbus.h.

◆ FunctionCode

Function codes.

Since
0.1.0
Enumerator
READ_HOLDING_REGISTERS 

Read holding registers.

Since
0.1.0
READ_INPUT_REGISTERS 

Read input registers.

Since
0.1.0
WRITE_SINGLE_REGISTER 

Write single register.

Since
0.1.0
READ_EXCEPTION_STATUS 

Read exception status.

Since
0.1.0

Definition at line 87 of file modbus.h.

◆ ResponseStatus

Status of response messages.

Since
0.1.0
Enumerator
QUEUED 

Waiting in queue.

Since
0.1.0
TRANSMIT 

Request being transmitted.

Since
0.1.0
WAITING 

Waiting for response.

Since
0.1.0
SUCCESS 

Response received.

Since
0.1.0
EXCEPTION 

Exception response received.

Since
0.1.0
FAILURE_INVALID 

Invalid request parameters.

Since
0.1.0
FAILURE_CRC 

Invalid CRC in response.

Since
0.1.0
FAILURE_TIMEOUT 

Request timed out.

Since
0.1.0
FAILURE_TOO_SHORT 

Response too short.

Since
0.1.0
FAILURE_TOO_LONG 

Response too long.

Since
0.1.0
FAILURE_ADDRESS 

Response from another device.

Since
0.1.0
FAILURE_FUNCTION 

Unexpected function code in response.

Since
0.1.0
FAILURE_LENGTH 

Incorrect response length.

Since
0.1.0
FAILURE_UNEXPECTED 

Received a response to broadcast request.

Since
0.1.0

Definition at line 99 of file modbus.h.

Variable Documentation

◆ DEFAULT_BROADCAST_TIMEOUT_MS

constexpr uint16_t uuid::modbus::DEFAULT_BROADCAST_TIMEOUT_MS = 1000
constexpr

Default time to wait after a broadcast request (in milliseconds).

Since
0.2.0

Definition at line 63 of file modbus.h.

◆ DEFAULT_UNICAST_TIMEOUT_MS

constexpr uint16_t uuid::modbus::DEFAULT_UNICAST_TIMEOUT_MS = 10000
constexpr

Default time to wait for a unicast response (in milliseconds).

Since
0.2.0

Definition at line 62 of file modbus.h.

◆ INTER_FRAME_TIMEOUT_MS

constexpr uint32_t uuid::modbus::INTER_FRAME_TIMEOUT_MS = 5
constexpr

Timeout between frames (in milliseconds).

9600 bps: 4ms 19200 bps: 2ms Minimum: 1.75ms

Allow an extra 1ms to compensate for timing at 1ms precision.

Since
0.1.0

Definition at line 61 of file modbus.h.

◆ logger

const uuid::log::Logger uuid::modbus::logger {reinterpret_cast<const __FlashStringHelper *>(__pstr__loggername), uuid::log::Facility::DAEMON}

uuid::log::Logger instance for Modbus library.

Since
0.1.0

Definition at line 37 of file modbus.cpp.

◆ MAX_MESSAGE_SIZE

constexpr uint16_t uuid::modbus::MAX_MESSAGE_SIZE = 256
constexpr

Maximum size of a message.

Since
0.1.0

Definition at line 47 of file modbus.h.

◆ MESSAGE_CRC_SIZE

constexpr uint16_t uuid::modbus::MESSAGE_CRC_SIZE = 2
constexpr

Size of message CRC.

Since
0.1.2

Definition at line 49 of file modbus.h.

◆ MESSAGE_HEADER_SIZE

constexpr uint16_t uuid::modbus::MESSAGE_HEADER_SIZE = 2
constexpr

Size of message header (device address and function code).

Since
0.1.2

Definition at line 48 of file modbus.h.