I still can not figure out a strange problem in data sending over serial communcation of wrt54gl router with Arduino.
First of all, with a very straight forward and simple code you see here, I expect to run it, type "this" and get it back, but I receive some white space, then the characters of the word "this" but not in the order!
first the code:
cmdbuf = (char*)malloc(sizeof(char) * MAXCMDLEN);
//char *cmdbuf = (char*)malloc(sizeof(char) * MAXCMDLEN);
sriBufCounter = 0;
while( Serial.available() && c != '\n' && sriBufCounter < MAXCMDLEN) //MAXCMDLEN 128
c = Serial.read();
cmdbuf[sriBufCounter++] = c;
void analyzeCommand(char* cmd, int BufCounter)
now the screen shot:
the next very strange behavior I can't understand is that if I comment the pointer allocation in the setup, and uncomment the one (currently commented) in the loop function, then even the unordered "this" won't appear when I type it!
Please help to reveal the secret!