10 years, 6 months ago.  This question has been closed. Reason: Got an awnser

Readline with serial

Hello all,

Is it possible to read a line using serial? I want to read data until a end of line char is read, is there a command for this or do I need to read character by character until I got my end of line character?

Rik

2 Answers

10 years, 6 months ago.

MODSERIAL has the option to generate an interrupt when the first end of line character is received, at which point you can empty its buffer. Depending on your line you can also use scanf, although that will also stop at whitespace characters (such as a space).

10 years, 6 months ago.

Solved it with the following:

 char buffer[20];
if (pc.readable())
        {
            pc.scanf("%s", &buffer);
        }