From 86407b9f6f95b24c798e4f64fe81b4ef5173fc89 Mon Sep 17 00:00:00 2001 From: GitforZhangXL <263866345@qq.com> Date: Mon, 27 Feb 2023 06:35:00 +0800 Subject: [PATCH] Change variable "skip_updates" and "skip_updates_counter" type from "uint8_t" to "uint16_t" (#4487) * change 'skip_updates'from 'uint8' to 'uint16_t' * Delete modbus_controller_fix.md * Update modbus_controller.h --------- Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- .../modbus_controller/binary_sensor/modbus_binarysensor.h | 2 +- esphome/components/modbus_controller/modbus_controller.h | 8 ++++---- .../components/modbus_controller/number/modbus_number.h | 2 +- .../components/modbus_controller/select/modbus_select.h | 2 +- .../components/modbus_controller/sensor/modbus_sensor.h | 2 +- .../components/modbus_controller/switch/modbus_switch.h | 2 +- .../modbus_controller/text_sensor/modbus_textsensor.h | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/esphome/components/modbus_controller/binary_sensor/modbus_binarysensor.h b/esphome/components/modbus_controller/binary_sensor/modbus_binarysensor.h index 3782416d4f..3a017c6f88 100644 --- a/esphome/components/modbus_controller/binary_sensor/modbus_binarysensor.h +++ b/esphome/components/modbus_controller/binary_sensor/modbus_binarysensor.h @@ -12,7 +12,7 @@ namespace modbus_controller { class ModbusBinarySensor : public Component, public binary_sensor::BinarySensor, public SensorItem { public: ModbusBinarySensor(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask, - uint8_t skip_updates, bool force_new_range) { + uint16_t skip_updates, bool force_new_range) { this->register_type = register_type; this->start_address = start_address; this->offset = offset; diff --git a/esphome/components/modbus_controller/modbus_controller.h b/esphome/components/modbus_controller/modbus_controller.h index 512fe0b25d..ccb0edf9c6 100644 --- a/esphome/components/modbus_controller/modbus_controller.h +++ b/esphome/components/modbus_controller/modbus_controller.h @@ -246,7 +246,7 @@ class SensorItem { uint8_t offset; uint8_t register_count; uint8_t response_bytes{0}; - uint8_t skip_updates; + uint16_t skip_updates; std::vector custom_data{}; bool force_new_range{false}; }; @@ -288,9 +288,9 @@ struct RegisterRange { uint16_t start_address; ModbusRegisterType register_type; uint8_t register_count; - uint8_t skip_updates; // the config value - SensorSet sensors; // all sensors of this range - uint8_t skip_updates_counter; // the running value + uint16_t skip_updates; // the config value + SensorSet sensors; // all sensors of this range + uint16_t skip_updates_counter; // the running value }; class ModbusCommandItem { diff --git a/esphome/components/modbus_controller/number/modbus_number.h b/esphome/components/modbus_controller/number/modbus_number.h index 9b447d831c..544d161cbc 100644 --- a/esphome/components/modbus_controller/number/modbus_number.h +++ b/esphome/components/modbus_controller/number/modbus_number.h @@ -14,7 +14,7 @@ using value_to_data_t = std::function(float); class ModbusNumber : public number::Number, public Component, public SensorItem { public: ModbusNumber(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask, - SensorValueType value_type, int register_count, uint8_t skip_updates, bool force_new_range) { + SensorValueType value_type, int register_count, uint16_t skip_updates, bool force_new_range) { this->register_type = register_type; this->start_address = start_address; this->offset = offset; diff --git a/esphome/components/modbus_controller/select/modbus_select.h b/esphome/components/modbus_controller/select/modbus_select.h index ffbbba390b..1c046b11d0 100644 --- a/esphome/components/modbus_controller/select/modbus_select.h +++ b/esphome/components/modbus_controller/select/modbus_select.h @@ -12,7 +12,7 @@ namespace modbus_controller { class ModbusSelect : public Component, public select::Select, public SensorItem { public: - ModbusSelect(SensorValueType sensor_value_type, uint16_t start_address, uint8_t register_count, uint8_t skip_updates, + ModbusSelect(SensorValueType sensor_value_type, uint16_t start_address, uint8_t register_count, uint16_t skip_updates, bool force_new_range, std::vector mapping) { this->register_type = ModbusRegisterType::HOLDING; // not configurable this->sensor_value_type = sensor_value_type; diff --git a/esphome/components/modbus_controller/sensor/modbus_sensor.h b/esphome/components/modbus_controller/sensor/modbus_sensor.h index 848d5f63de..65eb487c1c 100644 --- a/esphome/components/modbus_controller/sensor/modbus_sensor.h +++ b/esphome/components/modbus_controller/sensor/modbus_sensor.h @@ -12,7 +12,7 @@ namespace modbus_controller { class ModbusSensor : public Component, public sensor::Sensor, public SensorItem { public: ModbusSensor(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask, - SensorValueType value_type, int register_count, uint8_t skip_updates, bool force_new_range) { + SensorValueType value_type, int register_count, uint16_t skip_updates, bool force_new_range) { this->register_type = register_type; this->start_address = start_address; this->offset = offset; diff --git a/esphome/components/modbus_controller/switch/modbus_switch.h b/esphome/components/modbus_controller/switch/modbus_switch.h index 0f2d8f6e59..bfe46f3ac8 100644 --- a/esphome/components/modbus_controller/switch/modbus_switch.h +++ b/esphome/components/modbus_controller/switch/modbus_switch.h @@ -12,7 +12,7 @@ namespace modbus_controller { class ModbusSwitch : public Component, public switch_::Switch, public SensorItem { public: ModbusSwitch(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask, - uint8_t skip_updates, bool force_new_range) { + uint16_t skip_updates, bool force_new_range) { this->register_type = register_type; this->start_address = start_address; this->offset = offset; diff --git a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.h b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.h index 2e3be72034..9cc0db05a5 100644 --- a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.h +++ b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.h @@ -14,7 +14,7 @@ enum class RawEncoding { NONE = 0, HEXBYTES = 1, COMMA = 2 }; class ModbusTextSensor : public Component, public text_sensor::TextSensor, public SensorItem { public: ModbusTextSensor(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint8_t register_count, - uint16_t response_bytes, RawEncoding encode, uint8_t skip_updates, bool force_new_range) { + uint16_t response_bytes, RawEncoding encode, uint16_t skip_updates, bool force_new_range) { this->register_type = register_type; this->start_address = start_address; this->offset = offset;