mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
fix: modbus_textsensor response is too long in some cases (#6333)
This commit is contained in:
parent
3e2ce363a2
commit
0cdd0b295e
1 changed files with 3 additions and 3 deletions
|
@ -13,10 +13,10 @@ void ModbusTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Modbus Controller Te
|
|||
|
||||
void ModbusTextSensor::parse_and_publish(const std::vector<uint8_t> &data) {
|
||||
std::ostringstream output;
|
||||
uint8_t max_items = this->response_bytes;
|
||||
uint8_t items_left = this->response_bytes;
|
||||
uint8_t index = this->offset;
|
||||
char buffer[4];
|
||||
while ((max_items != 0) && index < data.size()) {
|
||||
while ((items_left > 0) && index < data.size()) {
|
||||
uint8_t b = data[index];
|
||||
switch (this->encode_) {
|
||||
case RawEncoding::HEXBYTES:
|
||||
|
@ -33,7 +33,7 @@ void ModbusTextSensor::parse_and_publish(const std::vector<uint8_t> &data) {
|
|||
output << (char) b;
|
||||
break;
|
||||
}
|
||||
|
||||
items_left--;
|
||||
index++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue