[modbus] Rework the client queue as a per-frame state machine (#17922)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Bonne Eggleston
2026-08-01 21:34:36 -05:00
committed by GitHub
co-authored by Claude Fable 5 J. Nick Koston
parent 5821915aad
commit d38a458de9
7 changed files with 1908 additions and 533 deletions
@@ -305,11 +305,8 @@ class ModbusController final : public PollingComponent, public modbus::ModbusCli
/// Deliberately shadows the deprecated ModbusClientDevice::send_raw() with identical semantics:
/// controller-level raw sends stay supported until the command machinery is replaced.
void send_raw(const std::vector<uint8_t> &payload) {
if (payload.empty()) {
// Through the guard like every other delivery, so a handler calling send_raw({}) cannot recurse.
this->trigger_not_sent({});
return;
}
if (payload.empty())
return; // refused at the door, like every invalid send; no callback follows
this->parent_->send_pdu(payload[0], std::span<const uint8_t>(payload).subspan(1), this);
}
/// Registers a sensor with the controller. Called by esphomes code generator