mirror of
https://github.com/esphome/esphome.git
synced 2024-11-24 12:06:26 +01:00
commit
4c83dc7c28
@ -35,7 +35,7 @@ def validate_adc_pin(value):
|
|||||||
if is_esp32c3():
|
if is_esp32c3():
|
||||||
if not (0 <= value <= 4): # ADC1
|
if not (0 <= value <= 4): # ADC1
|
||||||
raise cv.Invalid("ESP32-C3: Only pins 0 though 4 support ADC.")
|
raise cv.Invalid("ESP32-C3: Only pins 0 though 4 support ADC.")
|
||||||
if not (32 <= value <= 39): # ADC1
|
elif not (32 <= value <= 39): # ADC1
|
||||||
raise cv.Invalid("ESP32: Only pins 32 though 39 support ADC.")
|
raise cv.Invalid("ESP32: Only pins 32 though 39 support ADC.")
|
||||||
elif CORE.is_esp8266:
|
elif CORE.is_esp8266:
|
||||||
from esphome.components.esp8266.gpio import CONF_ANALOG
|
from esphome.components.esp8266.gpio import CONF_ANALOG
|
||||||
|
@ -96,23 +96,27 @@ bool Modbus::parse_modbus_byte_(uint8_t byte) {
|
|||||||
ESP_LOGW(TAG, "Modbus CRC Check failed! %02X!=%02X", computed_crc, remote_crc);
|
ESP_LOGW(TAG, "Modbus CRC Check failed! %02X!=%02X", computed_crc, remote_crc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
waiting_for_response = 0;
|
|
||||||
std::vector<uint8_t> data(this->rx_buffer_.begin() + data_offset, this->rx_buffer_.begin() + data_offset + data_len);
|
std::vector<uint8_t> data(this->rx_buffer_.begin() + data_offset, this->rx_buffer_.begin() + data_offset + data_len);
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (auto *device : this->devices_) {
|
for (auto *device : this->devices_) {
|
||||||
if (device->address_ == address) {
|
if (device->address_ == address) {
|
||||||
// Is it an error response?
|
// Is it an error response?
|
||||||
if ((function_code & 0x80) == 0x80) {
|
if ((function_code & 0x80) == 0x80) {
|
||||||
ESP_LOGW(TAG, "Modbus error function code: 0x%X exception: %d", function_code, raw[2]);
|
ESP_LOGD(TAG, "Modbus error function code: 0x%X exception: %d", function_code, raw[2]);
|
||||||
|
if (waiting_for_response != 0) {
|
||||||
device->on_modbus_error(function_code & 0x7F, raw[2]);
|
device->on_modbus_error(function_code & 0x7F, raw[2]);
|
||||||
|
} else {
|
||||||
|
// Ignore modbus exception not related to a pending command
|
||||||
|
ESP_LOGD(TAG, "Ignoring Modbus error - not expecting a response");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
device->on_modbus_data(data);
|
device->on_modbus_data(data);
|
||||||
}
|
}
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
waiting_for_response = 0;
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
ESP_LOGW(TAG, "Got Modbus frame from unknown address 0x%02X! ", address);
|
ESP_LOGW(TAG, "Got Modbus frame from unknown address 0x%02X! ", address);
|
||||||
}
|
}
|
||||||
@ -196,6 +200,7 @@ void Modbus::send_raw(const std::vector<uint8_t> &payload) {
|
|||||||
if (this->flow_control_pin_ != nullptr)
|
if (this->flow_control_pin_ != nullptr)
|
||||||
this->flow_control_pin_->digital_write(false);
|
this->flow_control_pin_->digital_write(false);
|
||||||
waiting_for_response = payload[0];
|
waiting_for_response = payload[0];
|
||||||
|
ESP_LOGV(TAG, "Modbus write raw: %s", hexencode(payload).c_str());
|
||||||
last_send_ = millis();
|
last_send_ = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2021.10.0b7"
|
__version__ = "2021.10.0b8"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user