I am trying to implement reprap g-code interpreter in Decimila board. The code compiles and uploaded to the board, and to test the board i send g-code commands like g00 x100 y100 from the arduino itself. However, the following code seem not to detect any end chars like '\n' or '\r' from arduino software, all i am getting is chars typed in the send box.
void get_and_do_command()
{
//read in characters if we got them.
if (Serial.available())
{
c = Serial.read();
if(c == '\r')
c = '\n';
// Throw away control chars except \n
if(c >= ' ' || c == '\n')
{
//newlines are ends of commands.
if (c != '\n')
{
Question is does arduino send any end char at all?
In the monitor window, it doesn't send any terminating characters. Otherwise, if you had multi-part text to enter (or wanted the character 'a' to send by itself) it would send "a\r\n" which would be bad.
What I do in serial mode is append a terminating character myself, such as '@'. When I encounter that in serial.read, I act as if it is the end of line as a workaround.
I believe I tried \r\n in the line, but it doesn't send that either.
I will only add that when using the Arduino serial.print function, then just the character(s) are sent. If a serial.println function is used then the function adds a ascii 13 (\r) character to the output.