3.4.1. Reading string registers

Reading string registers works slightly differently than reading an integer or a floating-point register. In contrast to other types of registers, a string register does not own a bitwidth. The actual size of the string that is read through it is determined by the string itself. 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), the offset128 parameter must be increased and the register must be read after every set of 16 bytes.

Example 3.6. 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
   }
}

Copyright © 2014 ARM. All rights reserved.ARM DUI 0842B
Non-ConfidentialID111014