mirror of
https://github.com/esphome/esphome.git
synced 2024-12-21 16:27:44 +01:00
[modbus] More clean-up (#7921)
This commit is contained in:
parent
b0e3ac01e8
commit
749a5e3348
@ -152,9 +152,9 @@ void ModbusController::on_modbus_read_registers(uint8_t function_code, uint16_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
SensorSet ModbusController::find_sensors_(ModbusRegisterType register_type, uint16_t start_address) const {
|
SensorSet ModbusController::find_sensors_(ModbusRegisterType register_type, uint16_t start_address) const {
|
||||||
auto reg_it = find_if(begin(this->register_ranges_), end(this->register_ranges_), [=](RegisterRange const &r) {
|
auto reg_it = std::find_if(
|
||||||
return (r.start_address == start_address && r.register_type == register_type);
|
std::begin(this->register_ranges_), std::end(this->register_ranges_),
|
||||||
});
|
[=](RegisterRange const &r) { return (r.start_address == start_address && r.register_type == register_type); });
|
||||||
|
|
||||||
if (reg_it == this->register_ranges_.end()) {
|
if (reg_it == this->register_ranges_.end()) {
|
||||||
ESP_LOGE(TAG, "No matching range for sensor found - start_address : 0x%X", start_address);
|
ESP_LOGE(TAG, "No matching range for sensor found - start_address : 0x%X", start_address);
|
||||||
@ -375,12 +375,12 @@ void ModbusController::loop() {
|
|||||||
if (!this->incoming_queue_.empty()) {
|
if (!this->incoming_queue_.empty()) {
|
||||||
auto &message = this->incoming_queue_.front();
|
auto &message = this->incoming_queue_.front();
|
||||||
if (message != nullptr)
|
if (message != nullptr)
|
||||||
process_modbus_data_(message.get());
|
this->process_modbus_data_(message.get());
|
||||||
this->incoming_queue_.pop();
|
this->incoming_queue_.pop();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// all messages processed send pending commands
|
// all messages processed send pending commands
|
||||||
send_next_command_();
|
this->send_next_command_();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ void ModbusSwitch::write_state(bool state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->parent_->queue_command(cmd);
|
this->parent_->queue_command(cmd);
|
||||||
publish_state(state);
|
this->publish_state(state);
|
||||||
}
|
}
|
||||||
// ModbusSwitch end
|
// ModbusSwitch end
|
||||||
} // namespace modbus_controller
|
} // namespace modbus_controller
|
||||||
|
Loading…
Reference in New Issue
Block a user