1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 08:41:59 +00:00

Update esphome/components/modbus_controller/modbus_controller.h

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
J. Nick Koston
2026-01-14 16:28:16 -10:00
committed by GitHub
parent a50654ef4d
commit 66e80fe13b

View File

@@ -286,7 +286,7 @@ class ServerRegister {
return std::to_string(value);
case SensorValueType::FP32_R:
case SensorValueType::FP32: {
// max 48: float with %.1f can be up to 41 chars (3.4e38 → 39 digits + sign + decimal + 1 digit) + null
// max 48: float with %.1f can be up to 42 chars incl. null (3.4e38 → 38 integer digits + decimal point + 1 decimal digit + optional sign)
char buf[48];
snprintf(buf, sizeof(buf), "%.1f", bit_cast<float>(static_cast<uint32_t>(value)));
return buf;