pldmtool: Add print message for the NumericEffectPDR

Refer to DSP0248_1.2.0 28.11 Table 76 and print the message for the
NumericEffecterPDR.

Tested with JSON file:
https://gist.github.com/lxwinspur/db1e6e37a14bdd626591b222e96f9d7e
 pldmtool platform GetPDR -d 3
 Encode request successfully
 Request Message:
 08 01 80 02 51 03 00 00 00 00 00 00 00 01 80 00 00 00
 Success in creating the socket : RC = 3
 Success in connecting to socket : RC = 0
 Success in sending message type as pldm to mctp : RC = 0
 Write to socket successful : RC = 18
 Total length:18
 Loopback response message:
 08 01 80 02 51 03 00 00 00 00 00 00 00 01 80 00 00 00
 On first recv(),response == request : RC = 0
 Total length: 101
 Shutdown Socket successful :  RC = 0
 Response Message:
 08 01 00 02 51 00 00 00 00 00 00 00 00 00 01 54 00 03 00 00 00 01 09 00 00 4a 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 15 00 03 00 00 00 00 00 01 04 00 00 80 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 Parsed Response Msg:
 nextRecordHandle: 0
 responseCount: 84
 recordHandle: 3
 PDRHeaderVersion: 1
 PDRType: 9
 recordChangeNumber: 0
 dataLength: 74
 PLDMTerminusHandle: 0
 effecterID: 3
 entityType: 0
 entityInstanceNumber: 0
 containerID: 0
 effecterSemanticID: 0
 effecterInit: 0
 effecterAuxiliaryNames: false
 baseUnit: 21
 unitModifier: 0
 rateUnit: 3
 baseOEMUnitHandle: 0
 auxUnit: 0
 auxUnitModifier: 0
 auxrateUnit: 0
 auxOEMUnitHandle: 0
 isLinear: true
 effecterDataSize: 4
 resolution: 1
 offset: 0
 accuracy: 0
 plusTolerance: 0
 minusTolerance: 0
 stateTransitionInterval: 0
 TransitionInterval: 0
 maxSettable: 0
 minSettable: 0
 rangeFieldFormat: 4
 rangeFieldSupport: 0
 nominalValue: 0
 normalMax: 0
 normalMin: 0
 ratedMax: 0
 ratedMin: 0

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I68c974d5fb993853b7f40e0eb078f47f30c80bce
diff --git a/tool/pldm_platform_cmd.cpp b/tool/pldm_platform_cmd.cpp
index db5cbed..c172d8f 100644
--- a/tool/pldm_platform_cmd.cpp
+++ b/tool/pldm_platform_cmd.cpp
@@ -56,7 +56,7 @@
     void parseResponseMsg(pldm_msg* responsePtr, size_t payloadLength) override
     {
         uint8_t completionCode = 0;
-        uint8_t recordData[255] = {0};
+        uint8_t recordData[65535] = {0};
         uint32_t nextRecordHndl = 0;
         uint32_t nextDataTransferHndl = 0;
         uint8_t transferFlag = 0;
@@ -76,7 +76,7 @@
             return;
         }
 
-        printPDRMsg(nextRecordHndl, respCnt, recordData, sizeof(recordData));
+        printPDRMsg(nextRecordHndl, respCnt, recordData);
     }
 
   private:
@@ -103,9 +103,9 @@
         }
     }
 
-    void printPDRFruRecordSet(uint8_t* data, size_t len)
+    void printPDRFruRecordSet(uint8_t* data)
     {
-        if (data == NULL || len == 0)
+        if (data == NULL)
         {
             return;
         }
@@ -124,14 +124,14 @@
         std::cout << "containerID: " << pdr->container_id << std::endl;
     }
 
-    void printPDREntityAssociation(uint8_t* data, size_t len)
+    void printPDREntityAssociation(uint8_t* data)
     {
         const std::map<uint8_t, const char*> assocationType = {
             {PLDM_ENTITY_ASSOCIAION_PHYSICAL, "Physical"},
             {PLDM_ENTITY_ASSOCIAION_LOGICAL, "Logical"},
         };
 
-        if (data == NULL || len == 0)
+        if (data == NULL)
         {
             return;
         }
@@ -171,15 +171,212 @@
         }
     }
 
-    void printPDR11(uint8_t* data, size_t len)
+    void printEffecterHdrPDR(pldm_pdr_hdr* hdr)
     {
-        if (data == NULL || len == 0)
+        std::cout << "recordHandle: " << hdr->record_handle << std::endl;
+        std::cout << "PDRHeaderVersion: " << unsigned(hdr->version)
+                  << std::endl;
+        std::cout << "PDRType: " << unsigned(hdr->type) << std::endl;
+        std::cout << "recordChangeNumber: " << hdr->record_change_num
+                  << std::endl;
+        std::cout << "dataLength: " << hdr->length << std::endl;
+    }
+
+    void printNumericEffecterPDR(uint8_t* data)
+    {
+        struct pldm_numeric_effecter_value_pdr* pdr =
+            (struct pldm_numeric_effecter_value_pdr*)data;
+        printEffecterHdrPDR(&pdr->hdr);
+        std::cout << "PLDMTerminusHandle: " << pdr->terminus_handle
+                  << std::endl;
+        std::cout << "effecterID: " << pdr->effecter_id << std::endl;
+        std::cout << "entityType: " << pdr->entity_type << std::endl;
+        std::cout << "entityInstanceNumber: " << pdr->entity_instance
+                  << std::endl;
+        std::cout << "containerID: " << pdr->container_id << std::endl;
+        std::cout << "effecterSemanticID: " << pdr->effecter_semantic_id
+                  << std::endl;
+        std::cout << "effecterInit: " << unsigned(pdr->effecter_init)
+                  << std::endl;
+        std::cout << "effecterAuxiliaryNames: "
+                  << (unsigned(pdr->effecter_auxiliary_names) ? "true"
+                                                              : "false")
+                  << std::endl;
+        std::cout << "baseUnit: " << unsigned(pdr->base_unit) << std::endl;
+        std::cout << "unitModifier: " << unsigned(pdr->unit_modifier)
+                  << std::endl;
+        std::cout << "rateUnit: " << unsigned(pdr->rate_unit) << std::endl;
+        std::cout << "baseOEMUnitHandle: "
+                  << unsigned(pdr->base_oem_unit_handle) << std::endl;
+        std::cout << "auxUnit: " << unsigned(pdr->aux_unit) << std::endl;
+        std::cout << "auxUnitModifier: " << unsigned(pdr->aux_unit_modifier)
+                  << std::endl;
+        std::cout << "auxrateUnit: " << unsigned(pdr->aux_rate_unit)
+                  << std::endl;
+        std::cout << "auxOEMUnitHandle: " << unsigned(pdr->aux_oem_unit_handle)
+                  << std::endl;
+        std::cout << "isLinear: "
+                  << (unsigned(pdr->is_linear) ? "true" : "false") << std::endl;
+        std::cout << "effecterDataSize: " << unsigned(pdr->effecter_data_size)
+                  << std::endl;
+        std::cout << "resolution: " << pdr->resolution << std::endl;
+        std::cout << "offset: " << pdr->offset << std::endl;
+        std::cout << "accuracy: " << pdr->accuracy << std::endl;
+        std::cout << "plusTolerance: " << unsigned(pdr->plus_tolerance)
+                  << std::endl;
+        std::cout << "minusTolerance: " << unsigned(pdr->minus_tolerance)
+                  << std::endl;
+        std::cout << "stateTransitionInterval: "
+                  << pdr->state_transition_interval << std::endl;
+        std::cout << "TransitionInterval: " << pdr->transition_interval
+                  << std::endl;
+        switch (pdr->effecter_data_size)
+        {
+            case PLDM_EFFECTER_DATA_SIZE_UINT8:
+                std::cout << "maxSettable: "
+                          << unsigned(pdr->max_set_table.value_u8) << std::endl;
+                std::cout << "minSettable: "
+                          << unsigned(pdr->min_set_table.value_u8) << std::endl;
+                break;
+            case PLDM_EFFECTER_DATA_SIZE_SINT8:
+                std::cout << "maxSettable: "
+                          << unsigned(pdr->max_set_table.value_s8) << std::endl;
+                std::cout << "minSettable: "
+                          << unsigned(pdr->min_set_table.value_s8) << std::endl;
+                break;
+            case PLDM_EFFECTER_DATA_SIZE_UINT16:
+                std::cout << "maxSettable: " << pdr->max_set_table.value_u16
+                          << std::endl;
+                std::cout << "minSettable: " << pdr->min_set_table.value_u16
+                          << std::endl;
+                break;
+            case PLDM_EFFECTER_DATA_SIZE_SINT16:
+                std::cout << "maxSettable: " << pdr->max_set_table.value_s16
+                          << std::endl;
+                std::cout << "minSettable: " << pdr->min_set_table.value_s16
+                          << std::endl;
+                break;
+            case PLDM_EFFECTER_DATA_SIZE_UINT32:
+                std::cout << "maxSettable: " << pdr->max_set_table.value_u32
+                          << std::endl;
+                std::cout << "minSettable: " << pdr->min_set_table.value_u32
+                          << std::endl;
+                break;
+            case PLDM_EFFECTER_DATA_SIZE_SINT32:
+                std::cout << "maxSettable: " << pdr->max_set_table.value_s32
+                          << std::endl;
+                std::cout << "minSettable: " << pdr->min_set_table.value_s32
+                          << std::endl;
+                break;
+            default:
+                break;
+        }
+        std::cout << "rangeFieldFormat: " << unsigned(pdr->range_field_format)
+                  << std::endl;
+        std::cout << "rangeFieldSupport: "
+                  << unsigned(pdr->range_field_support.byte) << std::endl;
+        switch (pdr->range_field_format)
+        {
+            case PLDM_RANGE_FIELD_FORMAT_UINT8:
+                std::cout << "nominalValue: "
+                          << unsigned(pdr->nominal_value.value_u8) << std::endl;
+                std::cout << "normalMax: " << unsigned(pdr->normal_max.value_u8)
+                          << std::endl;
+                std::cout << "normalMin: " << unsigned(pdr->normal_min.value_u8)
+                          << std::endl;
+                std::cout << "ratedMax: " << unsigned(pdr->rated_max.value_u8)
+                          << std::endl;
+                std::cout << "ratedMin: " << unsigned(pdr->rated_min.value_u8)
+                          << std::endl;
+                break;
+            case PLDM_RANGE_FIELD_FORMAT_SINT8:
+                std::cout << "nominalValue: "
+                          << unsigned(pdr->nominal_value.value_s8) << std::endl;
+                std::cout << "normalMax: " << unsigned(pdr->normal_max.value_s8)
+                          << std::endl;
+                std::cout << "normalMin: " << unsigned(pdr->normal_min.value_s8)
+                          << std::endl;
+                std::cout << "ratedMax: " << unsigned(pdr->rated_max.value_s8)
+                          << std::endl;
+                std::cout << "ratedMin: " << unsigned(pdr->rated_min.value_s8)
+                          << std::endl;
+                break;
+            case PLDM_RANGE_FIELD_FORMAT_UINT16:
+                std::cout << "nominalValue: " << pdr->nominal_value.value_u16
+                          << std::endl;
+                std::cout << "normalMax: " << pdr->normal_max.value_u16
+                          << std::endl;
+                std::cout << "normalMin: " << pdr->normal_min.value_u16
+                          << std::endl;
+                std::cout << "ratedMax: " << pdr->rated_max.value_u16
+                          << std::endl;
+                std::cout << "ratedMin: " << pdr->rated_min.value_u16
+                          << std::endl;
+                break;
+            case PLDM_RANGE_FIELD_FORMAT_SINT16:
+                std::cout << "nominalValue: " << pdr->nominal_value.value_s16
+                          << std::endl;
+                std::cout << "normalMax: " << pdr->normal_max.value_s16
+                          << std::endl;
+                std::cout << "normalMin: " << pdr->normal_min.value_s16
+                          << std::endl;
+                std::cout << "ratedMax: " << pdr->rated_max.value_s16
+                          << std::endl;
+                std::cout << "ratedMin: " << pdr->rated_min.value_s16
+                          << std::endl;
+                break;
+            case PLDM_RANGE_FIELD_FORMAT_UINT32:
+                std::cout << "nominalValue: " << pdr->nominal_value.value_u32
+                          << std::endl;
+                std::cout << "normalMax: " << pdr->normal_max.value_u32
+                          << std::endl;
+                std::cout << "normalMin: " << pdr->normal_min.value_u32
+                          << std::endl;
+                std::cout << "ratedMax: " << pdr->rated_max.value_u32
+                          << std::endl;
+                std::cout << "ratedMin: " << pdr->rated_min.value_u32
+                          << std::endl;
+                break;
+            case PLDM_RANGE_FIELD_FORMAT_SINT32:
+                std::cout << "nominalValue: " << pdr->nominal_value.value_s32
+                          << std::endl;
+                std::cout << "normalMax: " << pdr->normal_max.value_s32
+                          << std::endl;
+                std::cout << "normalMin: " << pdr->normal_min.value_s32
+                          << std::endl;
+                std::cout << "ratedMax: " << pdr->rated_max.value_s32
+                          << std::endl;
+                std::cout << "ratedMin: " << pdr->rated_min.value_s32
+                          << std::endl;
+                break;
+            case PLDM_RANGE_FIELD_FORMAT_REAL32:
+                std::cout << "nominalValue: " << pdr->nominal_value.value_f32
+                          << std::endl;
+                std::cout << "normalMax: " << pdr->normal_max.value_f32
+                          << std::endl;
+                std::cout << "normalMin: " << pdr->normal_min.value_f32
+                          << std::endl;
+                std::cout << "ratedMax: " << pdr->rated_max.value_f32
+                          << std::endl;
+                std::cout << "ratedMin: " << pdr->rated_min.value_f32
+                          << std::endl;
+                break;
+            default:
+                break;
+        }
+    }
+
+    void printStateEffecterPDR(uint8_t* data)
+    {
+        if (data == NULL)
         {
             return;
         }
 
         struct pldm_state_effecter_pdr* pdr =
             (struct pldm_state_effecter_pdr*)data;
+        printEffecterHdrPDR(&pdr->hdr);
+
         std::cout << "PLDMTerminusHandle: " << pdr->terminus_handle
                   << std::endl;
         std::cout << "effecterID: " << pdr->effecter_id << std::endl;
@@ -211,9 +408,9 @@
     }
 
     void printPDRMsg(const uint32_t nextRecordHndl, const uint16_t respCnt,
-                     uint8_t* data, size_t len)
+                     uint8_t* data)
     {
-        if (data == NULL || len == 0)
+        if (data == NULL)
         {
             return;
         }
@@ -232,14 +429,17 @@
 
         switch (pdr->type)
         {
+            case PLDM_NUMERIC_EFFECTER_PDR:
+                printNumericEffecterPDR(data);
+                break;
             case PLDM_STATE_EFFECTER_PDR:
-                printPDR11(data, len);
+                printStateEffecterPDR(data);
                 break;
             case PLDM_PDR_ENTITY_ASSOCIATION:
-                printPDREntityAssociation(data, len);
+                printPDREntityAssociation(data);
                 break;
             case PLDM_PDR_FRU_RECORD_SET:
-                printPDRFruRecordSet(data, len);
+                printPDRFruRecordSet(data);
                 break;
             default:
                 break;