BAS: Add logic to handle serial consoles that end lines with CR, LF, CR&LF, or CR|LF
This commit is contained in:
parent
9301ed8991
commit
ba4bb1c71b
@ -285,15 +285,21 @@ static int edit(int chn, int onl)
|
|||||||
#else
|
#else
|
||||||
if ((f->inCapacity + 1) < sizeof(f->inBuf))
|
if ((f->inCapacity + 1) < sizeof(f->inBuf))
|
||||||
{
|
{
|
||||||
/* Ignore carriage returns that may accompany a CRLF sequence.
|
#ifdef CONFIG_EOL_IS_BOTH_CRLF
|
||||||
* REVISIT: Some environments may have other line termination rules
|
/* Ignore carriage returns that may accompany a CRLF sequence. */
|
||||||
*/
|
|
||||||
|
|
||||||
if (ch != '\r')
|
if (ch != '\r')
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/* Is this a new line character */
|
/* Is this a new line character */
|
||||||
|
|
||||||
|
#ifdef CONFIG_EOL_IS_CR
|
||||||
|
if (ch != '\r')
|
||||||
|
#elif defined(CONFIG_EOL_IS_LF)
|
||||||
if (ch != '\n')
|
if (ch != '\n')
|
||||||
|
#elif defined(CONFIG_EOL_IS_EITHER_CRLF)
|
||||||
|
if (ch != '\n' && ch != '\r' )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/* No.. escape control characters other than newline and
|
/* No.. escape control characters other than newline and
|
||||||
* carriage return
|
* carriage return
|
||||||
@ -313,13 +319,28 @@ static int edit(int chn, int onl)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Echo the newline (or not) */
|
/* It is a newline */
|
||||||
|
|
||||||
else if (onl)
|
else
|
||||||
|
{
|
||||||
|
/* Echo the newline (or not). We always use newline
|
||||||
|
* termination when talking to the host.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (onl)
|
||||||
{
|
{
|
||||||
FS_putChar(chn, '\n');
|
FS_putChar(chn, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_EOL_IS_CR) || defined(CONFIG_EOL_IS_EITHER_CRLF)
|
||||||
|
/* If the host is talking to us with CR line terminations,
|
||||||
|
* switch to use LF internally.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ch = '\n';
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
f->inBuf[f->inCapacity++] = ch;
|
f->inBuf[f->inCapacity++] = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user