3.4.1. Accessing string registers

Accessing string registers works slightly differently than accessing 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 accessed 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 shows an example implementation:

Example 3.6. Accessing 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
                                 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;

      stringReg.offset128++; //increment offset for next read

Copyright © 2008-2011 ARM. All rights reserved.ARM DUI 0444H