This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Array pointer truncates

Guru 56033 points
Part Number: EK-TM4C1294XL


Tool/software: TI C/C++ Compiler

Hello again,

The pointer into reading back a storage array text string is not being auto incremented by C++ during a while loop serial passing of its cell contents. Only the first few text char (integers) if any are being transfer by the language and loop directives. I noticed UARTprintf() may of had the same issue thus codes a work around (va_start). That increments an array pointer compiler seemingly fails to write proper code for during compile time. C++ is supposed to be a high level language and manipulate address pointers into array cells being passed as data strings to called functions within while loops until '\0' NULL is reached.  TI Compilers seem to have issues with passing long text strings of mixed decimal & alpha via (char) combined from array cells typed as char or char*. It would seem this issue has always been a problem with TI compilers and has never been fixed. 

while loop call below incorrectly transfers maybe two sometimes six characters of 40 byte text string via storage array ExociteCIK. Why should the designer have to write a separate pointer increment loop in order to empty the text array contents (ExositeCIK[40])? That increment is being done by the called function via the local while loop below passing the array contents character pointer which truncates after passing only two characters. Like char type variables (short integers) passing data into similar handlers does not have this issue that oddly long text strings appear to have. 

The text array appears to be ASCII in CCS debug but sending it out without conversion produces the same bad results. 

Array string: 3b7da0a42c1a84abd41e0886b65768c9925b5a84

/* Send CIK to text box */

for(i=0; i < 39; i++)
{
   	//ArrayCik |= ExositeCIK[i];

  while(!(NexSendString("t20.txt=", ExositeCIK[i], 1)));
	
}
  • Unfortunately, I don't understand your problem.  Please pick one function that has this problem.  For the source file that contains this function, please follow the directions in the article How to Submit a Compiler Test Case.  In addition, please indicate the following:

    • The name of the function
    • A detailed description of how it acts now
    • A detailed description of how it should act instead

    Thanks and regards,

    -George

  • Perhaps you need to consult with your colleges as to why long array strings are not being transferred by the while loop in the example given above. It is an incremental read of the entire array contents,e.g. (39 bytes) and stops transfer from the array after byte 1 in single step debug. It is two source files involved in the transfer. It don't matter even if the called passed pointer attempts to buffer the entire 39 bytes, again the transfer stops after byte 1.

    All 39 array cells are filled ExositeCIK[40] buffer. So why won't the CPU transfer the entire array contents? Seemingly UARTprintf() in Tivaware utils (uartstdio.c) has the very same issue as they did an undocumented work around to resolve string transfers and never reported the issue to higher up minds. 

    Again single step F5/F6 the code and the array halts transfer after the 1st byte has been transferred. This is a reoccurring issue in CCS and I doubt seriously I'm the first one to report this.

    Snip of many data transfers of variables works as expected. Yet last line t2="54" is missing 38 array cells from ExociteCIK[40]. How much more plain can it be to see it ain't working.
    ,0,1ÿÿÿadd 55,0,1ÿÿÿampsx.val=0ÿÿÿwattsx.val=0ÿÿÿtaco.val=0ÿÿÿgTach.val=318ÿÿÿn2
    0.val=0ÿÿÿn21.val=0ÿÿÿn22.val=0ÿÿÿx0.val=0ÿÿÿx1.val=0ÿÿÿx2.val=0ÿÿÿx3.val=0ÿÿÿx4
    .val=0ÿÿÿx5.val=0ÿÿÿadd 3,0,ÿÿÿvoltsx.vvs0=3ÿÿÿvoltsx.vvs1=1ÿÿÿvoltsx.val=12333ÿ
    ÿÿLmostmpx.vvs0=2ÿÿÿLmostmpx.vvs1=1ÿÿÿLmostmpx.val=189ÿÿÿHmostmpx.vvs0=2ÿÿÿHmost
    mpx.vvs1=1ÿÿÿHmostmpx.val=122ÿÿÿfantaco.val=5457ÿÿÿcputmp.txt="37"ÿÿÿuseage.txt=
    "28"ÿÿÿgTach.val=ÿÿÿgLmos.val=1ÿÿÿgHmos.val=1ÿÿÿadd 3,0,1ÿÿÿadd 54,0,1ÿÿÿadd 55,
    0,1ÿÿÿampsx.val=0ÿÿÿwattsx.val=0ÿÿÿtaco.val=0ÿÿÿgTach.val=318ÿÿÿn20.val=0ÿÿÿn21.
    val=0ÿÿÿn22.val=0ÿÿÿx0.val=0ÿÿÿx1.val=0ÿÿÿx2.val=0ÿÿÿx3.val=0ÿÿÿx4.val=0ÿÿÿx5.va
    l=0ÿÿÿt2.txt="54"ÿÿÿ

  • This question is about as basic as a question can be and deserves some kind of answer. Perhaps like TI is aware of reported array transfer issues between functions by use of (char * dbyte) pointers passed into header of a called function via while loops or other means and are making efforts to correct all TI compilers to remedy the breakdown. 

  • BP101 said:
    The text array appears to be ASCII in CCS debug but sending it out without conversion produces the same bad results. 

    Confirmation of posted doubt would have aided as CCS debug was showing both decimal and character it was difficult to know was array char ASCII inside system.

    It was ASCII and did not require conversion. The other problem was Switch Case was falling through executing code that was not a matching argument to the static stored Switch(value) push / pop on stack. The static Switch(value) missing on stack POP allowed illegal entry to next Case. That was not always occurring but only after several calls to same passed char into Switch function of array[i] porting did the static Switch(value) go missing from the Static and Volatile Switch(value) was even worse. 

    So the only way to port the very long string (1st post) was 1 character at a time. Doing so asserted command "t20.txt=" clearing remote text box each time the command was sent with a new for loop array[i] character. The ExocitCIK[40] array would not pop its cells (read sensitive) as it did with UARTprintf(), that was the other confusing part. But the crux of the matter is the Switch Case is not working correctly as reported in this post and forum not only by me but others.

    It would seem under certain conditions interval invoking step into function, even a static Switch(value) gets lost on the stacking order!

  • FYI the Switch(value) was being primed in the current asserting case to HOLD in the current case push on the stack. Adding breaks under the asserting if clause break out did not fix this issue.

    The issue involves the Switch(value) being ignored by lower Case under the current executing case. Each Case must block entry and match Switch(value) or fall through without executing case step C++ directives. Earlier version compiles seemed to follow a Blocking convention did not require breaks when return } braces allowed pass through.

    Again adding additional "breaks" below the current executing case statements HOLD current Switch(value) until break directive were being ignored allowing entry into the next case. That seemingly is MPU stacking order related since switch(value) was static variable and controls entry or blocks entry to each case!