Fix typo and add and prepare Modbus component for hardware TX buffer and flow control

This commit is contained in:
brambo123 2024-03-12 20:39:13 +01:00
parent 4caa83f63f
commit bb08168a11
2 changed files with 7 additions and 5 deletions

View File

@ -190,10 +190,11 @@ void Modbus::send(uint8_t address, uint8_t function_code, uint16_t start_address
this->flow_control_pin_->digital_write(true);
this->write_array(data);
this->flush();
if (this->flow_control_pin_ != nullptr)
if (this->flow_control_pin_ != nullptr) {
this->flush();
this->flow_control_pin_->digital_write(false);
}
waiting_for_response = address;
last_send_ = millis();
ESP_LOGV(TAG, "Modbus write: %s", format_hex_pretty(data).c_str());
@ -213,9 +214,11 @@ void Modbus::send_raw(const std::vector<uint8_t> &payload) {
this->write_array(payload);
this->write_byte(crc & 0xFF);
this->write_byte((crc >> 8) & 0xFF);
this->flush();
if (this->flow_control_pin_ != nullptr)
if (this->flow_control_pin_ != nullptr) {
this->flush();
this->flow_control_pin_->digital_write(false);
}
waiting_for_response = payload[0];
ESP_LOGV(TAG, "Modbus write raw: %s", format_hex_pretty(payload).c_str());
last_send_ = millis();

View File

@ -215,7 +215,6 @@ CONFIG_SCHEMA = cv.All(
).extend(cv.COMPONENT_SCHEMA),
cv.has_at_least_one_key(CONF_TX_PIN, CONF_RX_PIN),
validate_invert_esp32,
validate_tx_buffer_support,
validate_flow_control_support,
)