FruDevice: add binary fields decoding
Binary fields are generally contains binary data, not text.
This commit adds printing binary fields in HEX representation, as
follows:
BOARD_INFO_AM1: "00112233"
Tested: tested with Fru contains binary custom fields
Change-Id: Iaf271e54dd02e2a00167da5657857dc49b3e9734
Signed-off-by: Andrei Kartashev <a.kartashev@yadro.com>
diff --git a/src/FruDevice.cpp b/src/FruDevice.cpp
index 14686d9..f4f904d 100644
--- a/src/FruDevice.cpp
+++ b/src/FruDevice.cpp
@@ -890,6 +890,17 @@
switch (type)
{
case FRUDataEncoding::binary:
+ {
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ for (i = 0; i < len; i++, iter++)
+ {
+ uint8_t val = static_cast<uint8_t>(*iter);
+ ss << std::setw(2) << static_cast<int>(val);
+ }
+ value = ss.str();
+ break;
+ }
case FRUDataEncoding::languageDependent:
/* For language-code dependent encodings, assume 8-bit ASCII */
value = std::string(iter, iter + len);