added second EOL character so that CR works as well as LF
#error Change SERIAL_LINE_CONF_BUFSIZE in contiki-conf.h.
#endif
-#ifndef IGNORE_CHAR
-#define IGNORE_CHAR(c) (c == 0x0d)
-#endif
-
#ifndef END
#define END 0x0a
#endif
+#ifndef END2
+#define END2 0x0d
+#endif
static struct ringbuf rxbuf;
static uint8_t rxbuf_data[BUFSIZE];
@@ -66,10 +65,6 @@ serial_line_input_byte(unsigned char c)
{
static uint8_t overflow = 0; /* Buffer overflow: ignore until END */
- if(IGNORE_CHAR(c)) {
- return 0;
- }
-
if(!overflow) {
/* Add character */
if(ringbuf_put(&rxbuf, c) == 0) {
@@ -79,7 +74,7 @@ serial_line_input_byte(unsigned char c)
} else {
/* Buffer overflowed:
* Only (try to) add terminator characters, otherwise skip */
- if(c == END && ringbuf_put(&rxbuf, c) != 0) {
+ if((c == END || c == END2) && ringbuf_put(&rxbuf, c) != 0) {
overflow = 0;
}
}
@@ -107,7 +102,7 @@ PROCESS_THREAD(serial_line_process, ev, data)
/* Buffer empty, wait for poll */
PROCESS_YIELD();
} else {
- if(c != END) {
+ if((c != END && c != END2)) {
if(ptr < BUFSIZE-1) {
buf[ptr++] = (uint8_t)c;
} else {
