ESPHome
2024.11.1
|
Data Structures | |
class | ModbusBinaryOutput |
class | ModbusBinarySensor |
class | ModbusCommandItem |
class | ModbusCommandSentTrigger |
class | ModbusController |
Modbus controller class. More... | |
class | ModbusFloatOutput |
class | ModbusNumber |
class | ModbusOfflineTrigger |
class | ModbusOnlineTrigger |
class | ModbusSelect |
class | ModbusSensor |
class | ModbusSwitch |
class | ModbusTextSensor |
struct | RegisterRange |
class | SensorItem |
class | SensorItemsComparator |
class | ServerRegister |
Typedefs | |
using | SensorSet = std::set< SensorItem *, SensorItemsComparator > |
using | value_to_data_t = std::function< float >(float) |
Functions | |
void | number_to_payload (std::vector< uint16_t > &data, int64_t value, SensorValueType value_type) |
Convert float value to vector<uint16_t> suitable for sending. More... | |
int64_t | payload_to_number (const std::vector< uint8_t > &data, SensorValueType sensor_value_type, uint8_t offset, uint32_t bitmask) |
Convert vector<uint8_t> response payload to number. More... | |
ModbusFunctionCode | modbus_register_read_function (ModbusRegisterType reg_type) |
ModbusFunctionCode | modbus_register_write_function (ModbusRegisterType reg_type) |
uint8_t | c_to_hex (char c) |
uint8_t | byte_from_hex_str (const std::string &value, uint8_t pos) |
Get a byte from a hex string hex_byte_from_str("1122",1) returns uint_8 value 0x22 == 34 hex_byte_from_str("1122",0) returns 0x11. More... | |
uint16_t | word_from_hex_str (const std::string &value, uint8_t pos) |
Get a word from a hex string. More... | |
uint32_t | dword_from_hex_str (const std::string &value, uint8_t pos) |
Get a dword from a hex string. More... | |
uint64_t | qword_from_hex_str (const std::string &value, uint8_t pos) |
Get a qword from a hex string. More... | |
template<typename T > | |
T | get_data (const std::vector< uint8_t > &data, size_t buffer_offset) |
Extract data from modbus response buffer. More... | |
bool | coil_from_vector (int coil, const std::vector< uint8_t > &data) |
Extract coil data from modbus response buffer Responses for coil are packed into bytes . More... | |
template<typename N > | |
N | mask_and_shift_by_rightbit (N data, uint32_t mask) |
Extract bits from value and shift right according to the bitmask if the bitmask is 0x00F0 we want the values frrom bit 5 - 8. More... | |
float | payload_to_float (const std::vector< uint8_t > &data, const SensorItem &item) |
Convert vector<uint8_t> response payload to float. More... | |
std::vector< uint16_t > | float_to_payload (float value, SensorValueType value_type) |
using esphome::modbus_controller::SensorSet = typedef std::set<SensorItem *, SensorItemsComparator> |
Definition at line 301 of file modbus_controller.h.
using esphome::modbus_controller::value_to_data_t = typedef std::function<float>(float) |
Definition at line 12 of file modbus_number.h.
|
strong |
Definition at line 19 of file modbus_controller.h.
|
strong |
Enumerator | |
---|---|
CUSTOM | |
COIL | |
DISCRETE_INPUT | |
HOLDING | |
READ |
Definition at line 41 of file modbus_controller.h.
|
strong |
Enumerator | |
---|---|
NONE | |
HEXBYTES | |
COMMA | |
ANSI |
Definition at line 12 of file modbus_textsensor.h.
|
strong |
Enumerator | |
---|---|
RAW | |
U_WORD | |
U_DWORD | |
S_WORD | |
S_DWORD | |
BIT | |
U_DWORD_R | |
S_DWORD_R | |
U_QWORD | |
S_QWORD | |
U_QWORD_R | |
S_QWORD_R | |
FP32 | |
FP32_R |
Definition at line 49 of file modbus_controller.h.
|
inline |
Get a byte from a hex string hex_byte_from_str("1122",1) returns uint_8 value 0x22 == 34 hex_byte_from_str("1122",0) returns 0x11.
value | string containing hex encoding |
position | offset in bytes. Because each byte is encoded in 2 hex digits the position of the original byte in the hex string is byte_pos * 2 |
Definition at line 113 of file modbus_controller.h.
|
inline |
Definition at line 103 of file modbus_controller.h.
|
inline |
Extract coil data from modbus response buffer Responses for coil are packed into bytes .
coil 3 is bit 3 of the first response byte coil 9 is bit 2 of the second response byte
coil | number of the cil |
data | modbus response buffer (uint8_t) |
Definition at line 182 of file modbus_controller.h.
|
inline |
Get a dword from a hex string.
value | string containing hex encoding |
position | offset in bytes. Because each byte is encoded in 2 hex digits the position of the original byte in the hex string is byte_pos * 2 |
Definition at line 135 of file modbus_controller.h.
|
inline |
Definition at line 541 of file modbus_controller.h.
T esphome::modbus_controller::get_data | ( | const std::vector< uint8_t > & | data, |
size_t | buffer_offset | ||
) |
Extract data from modbus response buffer.
T | one of supported integer data types int_8,int_16,int_32,int_64 |
data | modbus response buffer (uint8_t) |
buffer_offset | offset in bytes. |
Definition at line 156 of file modbus_controller.h.
N esphome::modbus_controller::mask_and_shift_by_rightbit | ( | N | data, |
uint32_t | mask | ||
) |
Extract bits from value and shift right according to the bitmask if the bitmask is 0x00F0 we want the values frrom bit 5 - 8.
the result is then shifted right by the position if the first right set bit in the mask Useful for modbus data where more than one value is packed in a 16 bit register Example: on Epever the "Length of night" register 0x9065 encodes values of the whole night length of time as D15 - D8 = hour, D7 - D0 = minute To get the hours use mask 0xFF00 and 0x00FF for the minute
data | an integral value between 16 aand 32 bits, |
bitmask | the bitmask to apply |
Definition at line 197 of file modbus_controller.h.
|
inline |
Definition at line 66 of file modbus_controller.h.
|
inline |
Definition at line 85 of file modbus_controller.h.
void esphome::modbus_controller::number_to_payload | ( | std::vector< uint16_t > & | data, |
int64_t | value, | ||
SensorValueType | value_type | ||
) |
Convert float value to vector<uint16_t> suitable for sending.
data | target for payload |
value | float value to convert |
value_type | defines if 16/32 or FP32 is used |
Definition at line 582 of file modbus_controller.cpp.
|
inline |
Convert vector<uint8_t> response payload to float.
data | payload with data |
item | SensorItem object |
Definition at line 528 of file modbus_controller.h.
int64_t esphome::modbus_controller::payload_to_number | ( | const std::vector< uint8_t > & | data, |
SensorValueType | sensor_value_type, | ||
uint8_t | offset, | ||
uint32_t | bitmask | ||
) |
Convert vector<uint8_t> response payload to number.
data | payload with the data to convert |
sensor_value_type | defines if 16/32/64 bits or FP32 is used |
offset | offset to the data in data |
bitmask | bitmask used for masking and shifting |
Definition at line 621 of file modbus_controller.cpp.
|
inline |
Get a qword from a hex string.
value | string containing hex encoding |
position | offset in bytes. Because each byte is encoded in 2 hex digits the position of the original byte in the hex string is byte_pos * 2 |
Definition at line 145 of file modbus_controller.h.
|
inline |
Get a word from a hex string.
value | string containing hex encoding |
position | offset in bytes. Because each byte is encoded in 2 hex digits the position of the original byte in the hex string is byte_pos * 2 |
Definition at line 125 of file modbus_controller.h.