#include <modbus_controller.h>
|
static ModbusCommandItem | create_read_command (ModbusController *modbusdevice, ModbusRegisterType register_type, uint16_t start_address, uint16_t register_count, std::function< void(ModbusRegisterType register_type, uint16_t start_address, const std::vector< uint8_t > &data)> &&handler) |
| factory methods More...
|
|
static ModbusCommandItem | create_read_command (ModbusController *modbusdevice, ModbusRegisterType register_type, uint16_t start_address, uint16_t register_count) |
| Create modbus read command Function code 02-04. More...
|
|
static ModbusCommandItem | create_write_multiple_command (ModbusController *modbusdevice, uint16_t start_address, uint16_t register_count, const std::vector< uint16_t > &values) |
| Create modbus read command Function code 02-04. More...
|
|
static ModbusCommandItem | create_write_single_command (ModbusController *modbusdevice, uint16_t start_address, uint16_t value) |
| Create modbus write multiple registers command Function 16 (10hex) Write Multiple Registers. More...
|
|
static ModbusCommandItem | create_write_single_coil (ModbusController *modbusdevice, uint16_t address, bool value) |
| Create modbus write single registers command Function 05 (05hex) Write Single Coil. More...
|
|
static ModbusCommandItem | create_write_multiple_coils (ModbusController *modbusdevice, uint16_t start_address, const std::vector< bool > &values) |
| Create modbus write multiple registers command Function 15 (0Fhex) Write Multiple Coils. More...
|
|
static ModbusCommandItem | create_custom_command (ModbusController *modbusdevice, const std::vector< uint8_t > &values, std::function< void(ModbusRegisterType register_type, uint16_t start_address, const std::vector< uint8_t > &data)> &&handler=nullptr) |
| Create custom modbus command. More...
|
|
static ModbusCommandItem | create_custom_command (ModbusController *modbusdevice, const std::vector< uint16_t > &values, std::function< void(ModbusRegisterType register_type, uint16_t start_address, const std::vector< uint8_t > &data)> &&handler=nullptr) |
| Create custom modbus command. More...
|
|
Definition at line 312 of file modbus_controller.h.
◆ create_custom_command() [1/2]
Create custom modbus command.
- Parameters
-
modbusdevice | pointer to the device to execute the command |
values | byte vector of data to be sent to the device. The complete payload must be provided with the exception of the crc codes |
handler | function called when the response is received. Default is just logging a response |
- Returns
- ModbusCommandItem with the prepared command
Definition at line 519 of file modbus_controller.cpp.
◆ create_custom_command() [2/2]
Create custom modbus command.
- Parameters
-
modbusdevice | pointer to the device to execute the command |
values | word vector of data to be sent to the device. The complete payload must be provided with the exception of the crc codes |
handler | function called when the response is received. Default is just logging a response |
- Returns
- ModbusCommandItem with the prepared command
Definition at line 538 of file modbus_controller.cpp.
◆ create_read_command() [1/2]
factory methods
Create modbus read command Function code 02-04
- Parameters
-
modbusdevice | pointer to the device to execute the command |
function_code | modbus function code for the read command |
start_address | modbus address of the first register to read |
register_count | number of registers to read |
handler | function called when the response is received |
- Returns
- ModbusCommandItem with the prepared command
Definition at line 400 of file modbus_controller.cpp.
◆ create_read_command() [2/2]
Create modbus read command Function code 02-04.
- Parameters
-
modbusdevice | pointer to the device to execute the command |
function_code | modbus function code for the read command |
start_address | modbus address of the first register to read |
register_count | number of registers to read |
- Returns
- ModbusCommandItem with the prepared command
Definition at line 414 of file modbus_controller.cpp.
◆ create_write_multiple_coils()
ModbusCommandItem esphome::modbus_controller::ModbusCommandItem::create_write_multiple_coils |
( |
ModbusController * |
modbusdevice, |
|
|
uint16_t |
start_address, |
|
|
const std::vector< bool > & |
values |
|
) |
| |
|
static |
Create modbus write multiple registers command Function 15 (0Fhex) Write Multiple Coils.
- Parameters
-
modbusdevice | pointer to the device to execute the command |
start_address | modbus address of the first register to read |
value | bool vector of values to be written to the registers |
- Returns
- ModbusCommandItem with the prepared command
Definition at line 468 of file modbus_controller.cpp.
◆ create_write_multiple_command()
ModbusCommandItem esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command |
( |
ModbusController * |
modbusdevice, |
|
|
uint16_t |
start_address, |
|
|
uint16_t |
register_count, |
|
|
const std::vector< uint16_t > & |
values |
|
) |
| |
|
static |
Create modbus read command Function code 02-04.
- Parameters
-
modbusdevice | pointer to the device to execute the command |
function_code | modbus function code for the read command |
start_address | modbus address of the first register to read |
register_count | number of registers to read |
handler | function called when the response is received |
- Returns
- ModbusCommandItem with the prepared command
Definition at line 430 of file modbus_controller.cpp.
◆ create_write_single_coil()
Create modbus write single registers command Function 05 (05hex) Write Single Coil.
- Parameters
-
modbusdevice | pointer to the device to execute the command |
start_address | modbus address of the first register to read |
value | uint16_t data to be written to the registers |
- Returns
- ModbusCommandItem with the prepared command
Definition at line 451 of file modbus_controller.cpp.
◆ create_write_single_command()
ModbusCommandItem esphome::modbus_controller::ModbusCommandItem::create_write_single_command |
( |
ModbusController * |
modbusdevice, |
|
|
uint16_t |
start_address, |
|
|
uint16_t |
value |
|
) |
| |
|
static |
Create modbus write multiple registers command Function 16 (10hex) Write Multiple Registers.
- Parameters
-
modbusdevice | pointer to the device to execute the command |
start_address | modbus address of the first register to read |
register_count | number of registers to read |
value | uint16_t single register value to write |
- Returns
- ModbusCommandItem with the prepared command
Definition at line 500 of file modbus_controller.cpp.
◆ is_equal()
bool esphome::modbus_controller::ModbusCommandItem::is_equal |
( |
const ModbusCommandItem & |
other | ) |
|
◆ send()
bool esphome::modbus_controller::ModbusCommandItem::send |
( |
| ) |
|
◆ should_retry()
bool esphome::modbus_controller::ModbusCommandItem::should_retry |
( |
uint8_t |
max_retries | ) |
|
|
inline |
Check if the command should be retried based on the max_retries parameter.
Definition at line 325 of file modbus_controller.h.
◆ function_code
◆ MAX_PAYLOAD_BYTES
const size_t esphome::modbus_controller::ModbusCommandItem::MAX_PAYLOAD_BYTES = 240 |
|
static |
◆ modbusdevice
ModbusController* esphome::modbus_controller::ModbusCommandItem::modbusdevice {nullptr} |
◆ on_data_func
std::function<void(ModbusRegisterType register_type, uint16_t start_address, const std::vector<uint8_t> &data)> esphome::modbus_controller::ModbusCommandItem::on_data_func |
◆ payload
std::vector<uint8_t> esphome::modbus_controller::ModbusCommandItem::payload = {} |
◆ register_address
uint16_t esphome::modbus_controller::ModbusCommandItem::register_address {0} |
◆ register_count
uint16_t esphome::modbus_controller::ModbusCommandItem::register_count {0} |
◆ register_type
◆ send_count_
uint8_t esphome::modbus_controller::ModbusCommandItem::send_count_ {0} |
|
protected |
The documentation for this class was generated from the following files: