it works, but when I type, say, @0099887766 and I expect 0099887766, I surprisingly get 009988776 without the last character. If I print bufCounter of my analyzeCommand(), it is always 9, even if I increase the size of MAXCMDLEN. It is probably another trivial mistake here, but to me it is a mystery how i of the loop() and bufCounter of the analyzer always are stopped at 9, even if I type a 10-char string!
The problem is with delay(10), but the problem with this problem is that, if I just delete it, then I don't get a command completely as things work faster than needed (even if I slow down to 57200 baud), but if I make it delay(12) it works!
Well, what is the right way of implementing this, so that all of my 10 char to be integrated once and in one variable, and then to print them?
No, the problem is that you're not accumulating a whole line of text into the buffer and processing it.
Change the print() in analyzeCommand() to a println(), and you'll see what's happening: the runtime calls loop(), it finds one character available, it reads that character, then calls analyzeCommand() and discards cmdbuf.
You need to change the while loop so it doesn't break until you get the line termination.
Another issue is the difference between an array of characters and a string. The Serial.print function is expecting a string, but you are passing it an array of characters.
The difference between an array of characters and a string is that a string is an array of characters that is NULL terminated.
You are not NULL terminating your array of characters.
as you see, I am passing "one char" each time, using "for" loop. I can use Serial.println() to print a '\n' at the end. Now do you see any issue with passing char array one by one?