Tool/software:
Hi ,
I am using TMS320F28335
I am trying to use string concat , strcpy , strcmp function for example testData[10] = {'\x02', 'A', 'B', 'C','2', 'D','0','M','\x03'};
to concat this testData to a string using concat and strcpy as shown below in code.
unsigned char extracted_data[5];
unsigned char Concatenat_Data[]={"\0"};
unsigned int receivedData[10] = {'\x02', 'F', 'R', 'M','2', 'D','0','M','\x03'};
unsigned int process_buffer()
{
unsigned int i,j, initial_index=0,last_index,c=0;
unsigned int is_cmd_ready = 0;
char String_Rxd[10] = {"\0"};
unsigned int buffer_size = sizeof(receivedData) / sizeof(receivedData[0]);
for (j = 1; j < buffer_size && receivedData[j] != '\x03'; j++)
{
if(receivedData[initial_index] == '\x02' && receivedData[8] == '\x03')
{
received_command[j - 1] = receivedData[j];
Concatenat_Data[c] = received_command[j - 1];
printf("Concatenat_Data: %c\n", Concatenat_Data[c]);
printf("Received data: %c\n", received_command[j - 1]);
c++;
}
else if(receivedData[0] != '\x02' || receivedData[8] != '\x03')
{
}
}
/*Concat function*/
concatenateStrings(String_Rxd, Concatenat_Data);
printf("String_Rxd: %s\n", String_Rxd);
/*Copy string function*/
strcpy(extracted_data, Concatenat_Data);
printf("extracted_data: %s\n", extracted_data);
c=0;
is_cmd_ready = 1;
return is_cmd_ready;
}
void concatenateStrings(char* str1, const char* str2)
{
while (*str1) {
++str1;
}
while (*str2) {
*str1++ = *str2++;
}
// Add the null-terminating character
*str1 = '\0';
}
i) First time when I run the code getting the concatenate string correctly, by using printf we are making sure data is properly concatenated.
Result :
String_Rxd: FRM
extracted_data:FRM
ii)But when we try to add additional function/code modification , we are not getting the Concatenated string string as previous result.
Result :
String_Rxd:
extracted_data:
1) Need clarification on this as we are trying to add additional function/code , we are not getting the string .
Any Changes in the configuration we should do for String or Any Memory size should we add ? in code composer
2) When we add more function in this sometimes we are getting result as this , some extra symbols are getting displayed
extracted_data: [empty ] or extracted_data: NP€Ëc÷ð`XÈî99x˜w:wW²
3) Does Code composer support strlen function
Thanks and Regards,
Taruna G