Skip to content

Commit

Permalink
SerialCommHub: use fmt::format's own hexadecimal prefix formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Moritz Barsnick <[email protected]>
  • Loading branch information
barsnick committed Jun 25, 2024
1 parent 6d09ce9 commit e8bb53f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/SerialCommHub/main/serial_communication_hubImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ serial_communication_hubImpl::perform_modbus_request(uint8_t device_address, tin
while (retry_counter > 0) {
auto current_trial = config.retries + 1 - retry_counter + 1;

EVLOG_debug << fmt::format("Trial {}/{}: calling {}(id {} addr {}(0x{:04x}) len {})", current_trial,
EVLOG_debug << fmt::format("Trial {}/{}: calling {}(id {} addr {}({:#06x}) len {})", current_trial,
config.retries + 1, tiny_modbus::FunctionCode_to_string_with_hex(function),
device_address, first_register_address, first_register_address, register_quantity);

try {
response = modbus.txrx(device_address, function, first_register_address, register_quantity,
config.max_packet_size, wait_for_reply, request);
} catch (const tiny_modbus::TinyModbusException& e) {
auto logmsg = fmt::format("Modbus call {} for device id {} addr {}(0x{:04x}) failed: {}",
auto logmsg = fmt::format("Modbus call {} for device id {} addr {}({:#06x}) failed: {}",
tiny_modbus::FunctionCode_to_string_with_hex(function), device_address,
first_register_address, first_register_address, e.what());

Expand Down

0 comments on commit e8bb53f

Please sign in to comment.