ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
esphome::modbus Namespace Reference

Data Structures

class  Modbus
 
class  ModbusDevice
 

Enumerations

enum  ModbusRole { CLIENT , SERVER }
 
enum class  ModbusFunctionCode : uint8_t {
  CUSTOM = 0x00 , READ_COILS = 0x01 , READ_DISCRETE_INPUTS = 0x02 , READ_HOLDING_REGISTERS = 0x03 ,
  READ_INPUT_REGISTERS = 0x04 , WRITE_SINGLE_COIL = 0x05 , WRITE_SINGLE_REGISTER = 0x06 , READ_EXCEPTION_STATUS = 0x07 ,
  DIAGNOSTICS = 0x08 , GET_COMM_EVENT_COUNTER = 0x0B , GET_COMM_EVENT_LOG = 0x0C , WRITE_MULTIPLE_COILS = 0x0F ,
  WRITE_MULTIPLE_REGISTERS = 0x10 , REPORT_SERVER_ID = 0x11 , READ_FILE_RECORD = 0x14 , WRITE_FILE_RECORD = 0x15 ,
  MASK_WRITE_REGISTER = 0x16 , READ_WRITE_MULTIPLE_REGISTERS = 0x17 , READ_FIFO_QUEUE = 0x18
}
 
enum class  ModbusRegisterType : uint8_t {
  CUSTOM = 0x00 , COIL = 0x01 , DISCRETE_INPUT = 0x02 , HOLDING = 0x03 ,
  READ = 0x04
}
 
enum class  ModbusExceptionCode : uint8_t {
  ILLEGAL_FUNCTION = 0x01 , ILLEGAL_DATA_ADDRESS = 0x02 , ILLEGAL_DATA_VALUE = 0x03 , SERVICE_DEVICE_FAILURE = 0x04 ,
  ACKNOWLEDGE = 0x05 , SERVER_DEVICE_BUSY = 0x06 , MEMORY_PARITY_ERROR = 0x08 , GATEWAY_PATH_UNAVAILABLE = 0x0A ,
  GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND = 0x0B
}
 

Functions

bool operator== (ModbusFunctionCode lhs, uint8_t rhs)
 
bool operator== (uint8_t lhs, ModbusFunctionCode rhs)
 
bool operator!= (ModbusFunctionCode lhs, uint8_t rhs)
 
bool operator!= (uint8_t lhs, ModbusFunctionCode rhs)
 
bool operator< (ModbusFunctionCode lhs, uint8_t rhs)
 
bool operator< (uint8_t lhs, ModbusFunctionCode rhs)
 
bool operator<= (ModbusFunctionCode lhs, uint8_t rhs)
 
bool operator<= (uint8_t lhs, ModbusFunctionCode rhs)
 
bool operator> (ModbusFunctionCode lhs, uint8_t rhs)
 
bool operator> (uint8_t lhs, ModbusFunctionCode rhs)
 
bool operator>= (ModbusFunctionCode lhs, uint8_t rhs)
 
bool operator>= (uint8_t lhs, ModbusFunctionCode rhs)
 

Variables

const uint8_t FUNCTION_CODE_USER_DEFINED_SPACE_1_INIT = 65
 Modbus definitions from specs: https://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf.
 
const uint8_t FUNCTION_CODE_USER_DEFINED_SPACE_1_END = 72
 
const uint8_t FUNCTION_CODE_USER_DEFINED_SPACE_2_INIT = 100
 
const uint8_t FUNCTION_CODE_USER_DEFINED_SPACE_2_END = 110
 
const uint8_t FUNCTION_CODE_MASK = 0x7F
 
const uint8_t FUNCTION_CODE_EXCEPTION_MASK = 0x80
 
const uint8_t MAX_NUM_OF_REGISTERS_TO_WRITE = 123
 
const uint8_t MAX_NUM_OF_REGISTERS_TO_READ = 125
 

Enumeration Type Documentation

◆ ModbusExceptionCode

enum class esphome::modbus::ModbusExceptionCode : uint8_t
strong
Enumerator
ILLEGAL_FUNCTION 
ILLEGAL_DATA_ADDRESS 
ILLEGAL_DATA_VALUE 
SERVICE_DEVICE_FAILURE 
ACKNOWLEDGE 
SERVER_DEVICE_BUSY 
MEMORY_PARITY_ERROR 
GATEWAY_PATH_UNAVAILABLE 
GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND 

Definition at line 66 of file modbus_definitions.h.

◆ ModbusFunctionCode

enum class esphome::modbus::ModbusFunctionCode : uint8_t
strong
Enumerator
CUSTOM 
READ_COILS 
READ_DISCRETE_INPUTS 
READ_HOLDING_REGISTERS 
READ_INPUT_REGISTERS 
WRITE_SINGLE_COIL 
WRITE_SINGLE_REGISTER 
READ_EXCEPTION_STATUS 
DIAGNOSTICS 
GET_COMM_EVENT_COUNTER 
GET_COMM_EVENT_LOG 
WRITE_MULTIPLE_COILS 
WRITE_MULTIPLE_REGISTERS 
REPORT_SERVER_ID 
READ_FILE_RECORD 
WRITE_FILE_RECORD 
MASK_WRITE_REGISTER 
READ_WRITE_MULTIPLE_REGISTERS 
READ_FIFO_QUEUE 

Definition at line 17 of file modbus_definitions.h.

◆ ModbusRegisterType

enum class esphome::modbus::ModbusRegisterType : uint8_t
strong
Enumerator
CUSTOM 
COIL 
DISCRETE_INPUT 
HOLDING 
READ 

Definition at line 54 of file modbus_definitions.h.

◆ ModbusRole

Enumerator
CLIENT 
SERVER 

Definition at line 13 of file modbus.h.

Function Documentation

◆ operator!=() [1/2]

bool esphome::modbus::operator!= ( ModbusFunctionCode lhs,
uint8_t rhs )
inline

Definition at line 42 of file modbus_definitions.h.

◆ operator!=() [2/2]

bool esphome::modbus::operator!= ( uint8_t lhs,
ModbusFunctionCode rhs )
inline

Definition at line 43 of file modbus_definitions.h.

◆ operator<() [1/2]

bool esphome::modbus::operator< ( ModbusFunctionCode lhs,
uint8_t rhs )
inline

Definition at line 44 of file modbus_definitions.h.

◆ operator<() [2/2]

bool esphome::modbus::operator< ( uint8_t lhs,
ModbusFunctionCode rhs )
inline

Definition at line 45 of file modbus_definitions.h.

◆ operator<=() [1/2]

bool esphome::modbus::operator<= ( ModbusFunctionCode lhs,
uint8_t rhs )
inline

Definition at line 46 of file modbus_definitions.h.

◆ operator<=() [2/2]

bool esphome::modbus::operator<= ( uint8_t lhs,
ModbusFunctionCode rhs )
inline

Definition at line 47 of file modbus_definitions.h.

◆ operator==() [1/2]

bool esphome::modbus::operator== ( ModbusFunctionCode lhs,
uint8_t rhs )
inline

Definition at line 40 of file modbus_definitions.h.

◆ operator==() [2/2]

bool esphome::modbus::operator== ( uint8_t lhs,
ModbusFunctionCode rhs )
inline

Definition at line 41 of file modbus_definitions.h.

◆ operator>() [1/2]

bool esphome::modbus::operator> ( ModbusFunctionCode lhs,
uint8_t rhs )
inline

Definition at line 48 of file modbus_definitions.h.

◆ operator>() [2/2]

bool esphome::modbus::operator> ( uint8_t lhs,
ModbusFunctionCode rhs )
inline

Definition at line 49 of file modbus_definitions.h.

◆ operator>=() [1/2]

bool esphome::modbus::operator>= ( ModbusFunctionCode lhs,
uint8_t rhs )
inline

Definition at line 50 of file modbus_definitions.h.

◆ operator>=() [2/2]

bool esphome::modbus::operator>= ( uint8_t lhs,
ModbusFunctionCode rhs )
inline

Definition at line 51 of file modbus_definitions.h.

Variable Documentation

◆ FUNCTION_CODE_EXCEPTION_MASK

const uint8_t esphome::modbus::FUNCTION_CODE_EXCEPTION_MASK = 0x80

Definition at line 64 of file modbus_definitions.h.

◆ FUNCTION_CODE_MASK

const uint8_t esphome::modbus::FUNCTION_CODE_MASK = 0x7F

Definition at line 63 of file modbus_definitions.h.

◆ FUNCTION_CODE_USER_DEFINED_SPACE_1_END

const uint8_t esphome::modbus::FUNCTION_CODE_USER_DEFINED_SPACE_1_END = 72

Definition at line 12 of file modbus_definitions.h.

◆ FUNCTION_CODE_USER_DEFINED_SPACE_1_INIT

const uint8_t esphome::modbus::FUNCTION_CODE_USER_DEFINED_SPACE_1_INIT = 65

◆ FUNCTION_CODE_USER_DEFINED_SPACE_2_END

const uint8_t esphome::modbus::FUNCTION_CODE_USER_DEFINED_SPACE_2_END = 110

Definition at line 15 of file modbus_definitions.h.

◆ FUNCTION_CODE_USER_DEFINED_SPACE_2_INIT

const uint8_t esphome::modbus::FUNCTION_CODE_USER_DEFINED_SPACE_2_INIT = 100

Definition at line 14 of file modbus_definitions.h.

◆ MAX_NUM_OF_REGISTERS_TO_READ

const uint8_t esphome::modbus::MAX_NUM_OF_REGISTERS_TO_READ = 125

Definition at line 83 of file modbus_definitions.h.

◆ MAX_NUM_OF_REGISTERS_TO_WRITE

const uint8_t esphome::modbus::MAX_NUM_OF_REGISTERS_TO_WRITE = 123

Definition at line 79 of file modbus_definitions.h.