1 Reply Latest reply on May 17, 2017 2:12 AM by user_1377889

    SMBusSlave_v5_20 problem

    vadimv1144_2472191

      In the code generated for the SMBusSlave_v5_20 component there is an error in the code that validates the buffer length:

         

      In the header, the validity of the index is checked as follows:

         

      /* Helpers to check if a command size is valid. Greater or equal is used to take
      * into account the PEC byte. For example, when the PEC is enabled and a host
      * writes to a word command, the correct index value is 2 if the host does not
      * send PEC, and 3 if it does. The index value greater than 3 results in a Host
      * Sends Too Many Bytes fault and is detected in the ISR.
      */
      #define HOST_PMBusSlave_CMD_LEN_VALID                  (HOST_PMBusSlave_bufferIndex >= HOST_PMBusSlave_bufferSize)

         

      So the check is valid when the index exceeds the size of the buffer. 

         

      Here is the usage of the above check:

         

      case HOST_PMBusSlave_MFR_ID:
            if(HOST_PMBusSlave_CMD_LEN_VALID)
            {
                     (void)memcpy((void *)HOST_PMBusSlave_cmdDataPtr, (const void *)HOST_PMBusSlave_buffer, (uint32)HOST_PMBusSlave_bufferSize);
             }
             break;

         

      The sign in the expression should be changed to "<="