Fix float encoding in modbus server (#6986)

This commit is contained in:
Petapton 2024-06-26 02:08:16 +02:00 committed by Jesse Hills
parent 169fb79c97
commit bbd7c9cf86
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

View file

@ -116,7 +116,8 @@ void ModbusController::on_modbus_read_registers(uint8_t function_code, uint16_t
ESP_LOGD(TAG, "Matched register. Address: 0x%02X. Value type: %zu. Register count: %u. Value: %0.1f.",
server_register->address, static_cast<uint8_t>(server_register->value_type),
server_register->register_count, value);
number_to_payload(sixteen_bit_response, value, server_register->value_type);
std::vector<uint16_t> payload = float_to_payload(value, server_register->value_type);
sixteen_bit_response.insert(sixteen_bit_response.end(), payload.cbegin(), payload.cend());
current_address += server_register->register_count;
found = true;
break;