3.4.2 Reading from string registers

Reading from string registers works slightly differently to reading from an integer or a floating-point register. In contrast to other types of registers, a string register does not own a bitwidth.

The string itself determines the actual size of the string that is read through the string register. The bytes of the data buffer in CADIReg_t are read sequentially until the terminating '\0' character is reached. For a string longer than 16 bytes (including the terminating character), increase the offset128 parameter and read the register after every set of 16 bytes.

Reading string registers
// "register_info" contains information on a string register.
eslapi::CADIReg_t stringReg; //only one CADIReg_t required
eslapi::CADIReturn_t status;
if (register_info.display == eslapi::CADI_REGTYPE_STRING)
{
   std::string readString = "";
   // Set up "stringReg".
   stringReg.regNumber = register_info.regNumber;
   stringReg.offset128 = 0;
   stringReg.isUndefined = false;
   stringReg.attribute = register_info.attribute;
   bool stringFinished = false;
   while (!stringFinished)
   {
      uint32_t numOfRegsRead = 0;
      memset(stringReg.bytes, 0, sizeof(uint8_t) * 16); //init buffer
      status = cadi->CADIRegRead(1, //regCount
                                 &stringReg,
                                 &numOfRegsRead,
                                 0); //do no side effects
      // ...check status and number of actually read registers...
      for (uint32_t i = 0; i < 16; i++)
      {
         char currentChar = stringReg.bytes[i];
         readString.append(1, currentChar);
         if (currentChar == '\0') // Reached end of string, leaving loop
         {
            stringFinished = true;
            break;
         }
      }
      stringReg.offset128++; // Increment offset for next read.
   }
}
Non-ConfidentialPDF file icon PDF versionARM 100963_0200_00_en
Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved.