mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	fix: modbus_textsensor response is too long in some cases (#6333)
This commit is contained in:
		| @@ -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++; | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user