mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[cli] fix output of fractional part of ping average round-trip time (#11587)
This commit addresses an issue where the fractional part of the ping average round-trip time (RTT) was not consistently formatted. Previously, it used ".%u" with `(avgRoundTripTime % 1000)` which could omit leading zeros for fractional values. It now uses ".%03u" to ensure three digits are always displayed, padding with leading zeros when necessary.
This commit is contained in:
committed by
GitHub
parent
8a19434b8a
commit
00e4e42c57
@@ -236,7 +236,7 @@ void PingSender::HandlePingStatistics(const otPingSenderStatistics *aStatistics)
|
||||
uint32_t avgRoundTripTime =
|
||||
1000 * static_cast<uint64_t>(aStatistics->mTotalRoundTripTime) / aStatistics->mReceivedCount;
|
||||
|
||||
OutputFormat(" Round-trip min/avg/max = %u/%u.%u/%u ms.", aStatistics->mMinRoundTripTime,
|
||||
OutputFormat(" Round-trip min/avg/max = %u/%u.%03u/%u ms.", aStatistics->mMinRoundTripTime,
|
||||
static_cast<uint16_t>(avgRoundTripTime / 1000), static_cast<uint16_t>(avgRoundTripTime % 1000),
|
||||
aStatistics->mMaxRoundTripTime);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user