Hi Guys
I am facing a very strange problem related to the strlen inbuilt function in the keil C51.
I wrote few functions as follows:
Function 1 :
void ModMasterData(uChar *,uChar *,uChar,struct Master *);
Function 2 :
void ModFrameGenerator(struct Master *);
the typedef definition for the uChar is :
typedef unsigned char uChar;
What I have done is that I am pasing the source string defined as
code char *STestString = "Hello";
to the function ModMasterData as the first argument and also the strlen of that string as the third argument like this:
ModMasterData(STestString,&Command,strlen(STestString),&MasterBuf);
After that the ModFrameGenerator function is called which concatenates all the contents into a single Frame or array of size 25.
But what I seen by continuously monitoring the array over the Uart that it behaves correctly upto 15 or 20 rounds of data that is thrown over the Uart and after that start missing the data string in the array.
The data that should come is as follows:
9G5Hello6
But I got in this format
9G<00>$<00><00><00><00>
after 30-40 cycles of proper throwing of data over the Uart.
My question is that how can pointer or any function like strlen can start malfunctioning in between the flow of code, because in the first case it behaves correctly and than all of sudden it start throwing the garbage value.