I do have a EK-TM4C1294XL , but this is probably a general C code question, and if I enter that board, I am locked into posting on the board forum!?
I receive command strings by UDP. After handling a command, I return a string consisting of a number of elements stitched together in a new string.
Or in case of an unknown command or some conversion error, I return a Not Acknowleded (NAC).
I have somehow run into a problem. If the return string is too long, my return address on the stack is overwritten!
If the return strings are short enough, everything works for thousands of commands!
void ACK(char Cmd[], char Answ[]) { char res[] = "0 "; strcat(res, Cmd); strcat(res, " "); strcat(res, Answ); //If res string ends up too long, return address is overwritten! udp_server_send(res); } void udp_incomming(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port) { char Command[25]; char Catch[5], SweepParam[9]; char Answer[] = "----"; char b[10]; unsigned short c; int a, i, j; uint32_t Cardinal; if (p != NULL) { memcpy(Command,p->payload,p->len); Command[p->len]=0; memcpy(Catch,Command,4); Catch[4]='\0'; ConvertError=false; //Catch is a short string used to figure out which command I have received --- if (ConvertError) NAC(Command); else ACK(Command, Answer); } pbuf_free(p); }
I am not all that well educated in C, but somehow I should clear more space on the stack, or maybe start using pointers.
But all that 'star'-stuff is still pretty alien to me!
How do I proceed?