From 6edfc5c16cfe85e7c50a3574e3d6ef81b1895ad4 Mon Sep 17 00:00:00 2001 From: Ratan Gupta Date: Wed, 31 Jan 2018 21:41:45 +0530 Subject: FRU: Change the type code to ASCII In board and product area format there is type and length field for each field. 6-7 bit of typelength field specifies the type and first five bits specify the length.a eg:- Board Manufacturer type/length byte followed by actual number of bytes defined in first five bits of type length of Board Manufacturer field. Change-Id: Iaaf608cc93829fb1dd8d0c54a49bd467a7cadbea Signed-off-by: Ratan Gupta --- ipmi_fru_info_area.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'ipmi_fru_info_area.cpp') diff --git a/ipmi_fru_info_area.cpp b/ipmi_fru_info_area.cpp index 24b8f0b..64fa222 100644 --- a/ipmi_fru_info_area.cpp +++ b/ipmi_fru_info_area.cpp @@ -33,6 +33,8 @@ static constexpr auto endOfCustomFields = 0xC1; static constexpr auto commonHeaderFormatSize = 0x8; //size in bytes static constexpr auto manufacturingDateSize = 0x3; static constexpr auto areaSizeOffset = 0x1; +static constexpr uint8_t typeASCII = 0xC0; +static constexpr auto maxRecordAttributeValue = 0x1F; /** * @brief Format Beginning of Individual IPMI FRU Data Section @@ -120,8 +122,19 @@ void appendData(const Property& key, const PropertyMap& propMap, { value.erase(0, 2); } - data.emplace_back(value.length()); - std::copy(value.begin(), value.end(), std::back_inserter(data)); + + // 5 bits for length + // if length is greater then 31(2^5) bytes then trim the data to 31 bytess. + auto valueLength = (value.length() > maxRecordAttributeValue) ? + maxRecordAttributeValue : value.length(); + // 2 bits for type + // Set the type to ascii + uint8_t typeLength = valueLength | ipmi::fru::typeASCII; + + data.emplace_back(typeLength); + std::copy(value.begin(), + value.begin() + valueLength, + std::back_inserter(data)); } else { -- cgit v1.2.1