read an entire line from the serial port

Hi, I want to create kindof a shell in my Arduino. For this reason, I need to read the entire line that comes in (the line will contain a command and parameters).
Think of the Cisco IOS interface. That's kindof what I want to do.

I have noticed that the Serial.available() call returns the number of characters in the buffer. But it reads the buffer just in a way as characters come in. So that's not very reliable. Obviously I need to read the buffer until ther's a newline and then I need to react.

For this purpose I need to collect the incoming characters across many loop iterations. But I don't know how to store values outside of the loop without re-allocating the variables again and again.

My questions:
a) Is there a method to grab the entire input line?
b) How can I store incoming strings outside the loop function?

Thanks ahead
Markus

But it reads the buffer just in a way as characters come in. So that's not very reliable.

What makes you say that it isn't reliable?

b) How can I store incoming strings outside the loop function

Declare them outside of the "loop" function.

Hi,

I want to create kindof a shell in my Arduino.

Somebody did this already .... ( it's my favourite Arduino project)

but if you're out to something completely different you can at least have a look at the projects code

Eberhard

Hi Guys,

Thanks a lot four your hints. I also found a solution.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1237996427

It's a little confusing to see that you cannot really catch the newline in the Arduino serial interface, but it works when you use minicom.
Greetings
Markus