/* Calculates the 16-bit CRC according to the Modbus RTU specification.  */
static uint16_t XcpTpMbRtuCrcCalculate(uint8_t const *data, uint16_t len)
/* Calculates the 16-bit CRC according to the Modbus RTU specification.  */
static uint16_t XcpTpMbRtuCrcCalculate(uint8_t const *data, uint16_t len)
{
  uint16_t result = 0;
  uint8_t  locCRCHi = 0xFF;
  uint8_t  locCRCLo = 0xFF;
  uint16_t idx;
  assert((data != NULL) && (len > 0));
  if ((data != NULL) && (len > 0))
  {
    while (len--)
    {
      idx = locCRCLo ^ *data++;
      locCRCLo = locCRCHi ^ CRCHi[idx];
      locCRCHi = CRCLo[idx];
    }
    result = (locCRCHi << 8 | locCRCLo);
  }
  return result;
}