[cli] add OutputUint64() for 64-bit integer value in decimal format (#8354)

This commit also adds a helper `Uint64ToString()` method to convert a
`uint64_t` to decimal format string. The new methods allow us to
output `uint64_t` values without needing to cast to `unsigned long
long` and/or use of `%llu` (which may not be provided by certain
embedded libraries).
This commit is contained in:
Abtin Keshavarzian
2022-11-07 09:35:27 +01:00
committed by GitHub
parent ba826ffb2a
commit 727002e9fe
6 changed files with 149 additions and 40 deletions
+6 -4
View File
@@ -51,12 +51,14 @@ otError Dataset::Print(otOperationalDataset &aDataset)
{
if (aDataset.mComponents.mIsPendingTimestampPresent)
{
OutputLine("Pending Timestamp: %lu", aDataset.mPendingTimestamp.mSeconds);
OutputFormat("Pending Timestamp: ");
OutputUint64Line(aDataset.mPendingTimestamp.mSeconds);
}
if (aDataset.mComponents.mIsActiveTimestampPresent)
{
OutputLine("Active Timestamp: %lu", aDataset.mActiveTimestamp.mSeconds);
OutputFormat("Active Timestamp: ");
OutputUint64Line(aDataset.mActiveTimestamp.mSeconds);
}
if (aDataset.mComponents.mIsChannelPresent)
@@ -264,7 +266,7 @@ template <> otError Dataset::Process<Cmd("activetimestamp")>(Arg aArgs[])
{
if (sDataset.mComponents.mIsActiveTimestampPresent)
{
OutputLine("%lu", sDataset.mActiveTimestamp.mSeconds);
OutputUint64Line(sDataset.mActiveTimestamp.mSeconds);
}
}
else
@@ -666,7 +668,7 @@ template <> otError Dataset::Process<Cmd("pendingtimestamp")>(Arg aArgs[])
{
if (sDataset.mComponents.mIsPendingTimestampPresent)
{
OutputLine("%lu", sDataset.mPendingTimestamp.mSeconds);
OutputUint64Line(sDataset.mPendingTimestamp.mSeconds);
}
}
else