Fix float encoding in modbus server (#6986)

This commit is contained in:
Petapton 2024-06-26 02:08:16 +02:00 committed by GitHub
parent bc26de2d68
commit cc4f1c667e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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;