mirror of
https://github.com/esphome/esphome.git
synced 2026-10-06 02:51:29 +00:00
[modbus] Typed send helpers; migrate in-tree callers off send() (#17859)
This commit is contained in:
@@ -718,4 +718,25 @@ void Modbus::clear_rx_buffer_(const LogString *reason, bool warn, size_t bytes_t
|
||||
}
|
||||
}
|
||||
|
||||
void ModbusClientDevice::read_entities(EntityType entity_type, uint16_t start_address, uint16_t number_of_entities) {
|
||||
switch (entity_type) {
|
||||
case EntityType::HOLDING:
|
||||
this->read_holding_registers(start_address, number_of_entities);
|
||||
return;
|
||||
case EntityType::INPUT_REGISTER:
|
||||
this->read_input_registers(start_address, number_of_entities);
|
||||
return;
|
||||
case EntityType::COIL:
|
||||
this->read_coils(start_address, number_of_entities);
|
||||
return;
|
||||
case EntityType::DISCRETE_INPUT:
|
||||
this->read_discrete_inputs(start_address, number_of_entities);
|
||||
return;
|
||||
default:
|
||||
ESP_LOGW(TAG, "Invalid entity type for read_entities: %d", (int) entity_type);
|
||||
this->on_not_sent(); // every rejected send is signalled, like send_pdu()'s own refusals
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace esphome::modbus
|
||||
|
||||
Reference in New Issue
Block a user