This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How recieve string into controller

Hi everybody!

I work with Keil C251 uVision2.
in my programm i want to recieve string into controller. i have an array of characters incom[20], which i use as a buffer for recieving string. i recieve current byte into variable bufIn and then replace it into my array:

 1.  	strcat(incom, bufIn);

or
 2.     incom[i] = bufIn;
	i++;
in 2 cases before (1) & (2) i test with my routine Print(unsigned char) and can see that every next byte is recieved into bufIn variable, and after (1) & (2) i can see that byte is stored into the next byte of incom[] array.
But after recieving the whole string while testing array:
for(i = 0; i < 20; i++)
     Print(incom[i]);
i can see the empty string with only the last recieved byte on the last place, for example: " a".
If anybody can help me to recieve the whole string?
And else. Why i can't create any array of characters more than 20 symbols?
Thaks.
Gennady.

Parents
  •  1.  	strcat(incom, bufIn);
    The standard strcat() library function needs both its arguments to be strings (ie, NULL-terminated)

    Are you having some sort of integer-promotion problem?
    ie, somewhere your char gets converted to an int then, when it goes back to a char, you get only the high-order byte - which is zero (ie, NULL)

    Why i can't create any array of characters more than 20 symbols?

    That shouldn't be a problem - what are your symptoms?


Reply
  •  1.  	strcat(incom, bufIn);
    The standard strcat() library function needs both its arguments to be strings (ie, NULL-terminated)

    Are you having some sort of integer-promotion problem?
    ie, somewhere your char gets converted to an int then, when it goes back to a char, you get only the high-order byte - which is zero (ie, NULL)

    Why i can't create any array of characters more than 20 symbols?

    That shouldn't be a problem - what are your symptoms?


Children