mirror of
https://github.com/esphome/esphome.git
synced 2026-10-05 10:31:29 +00:00
[modbus] Frame accessors, PDU-relative lengths, and span-based send_pdu (#17846)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
58385bebff
commit
eaa79b3696
@@ -298,6 +298,17 @@ class ModbusController final : public PollingComponent, public modbus::ModbusCli
|
||||
|
||||
/// queues a modbus command in the send queue
|
||||
void queue_command(const ModbusCommandItem &command);
|
||||
/// Sends a raw payload (address byte + PDU, no CRC) with responses routed back to this controller.
|
||||
/// The payload carries its own address byte, which may differ from this controller's address.
|
||||
/// 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()) {
|
||||
this->on_not_sent(); // match the hub-level send_raw(): a refused send is always signalled
|
||||
return;
|
||||
}
|
||||
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
|
||||
void add_sensor_item(SensorItem *item) { sensorset_.insert(item); }
|
||||
/// called when a modbus response was parsed without errors
|
||||
|
||||
Reference in New Issue
Block a user