From 5047b661aff7be581d42e54e791c9a5fcf25224c Mon Sep 17 00:00:00 2001 From: BlackMark Date: Fri, 2 Aug 2019 18:22:38 +0200 Subject: [PATCH] Changed example to use peeking --- uart/main.cpp | 14 +++++++++++++- uart/uart | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/uart/main.cpp b/uart/main.cpp index 2d09849..cc2f359 100644 --- a/uart/main.cpp +++ b/uart/main.cpp @@ -21,8 +21,20 @@ void newUartUsage() while (true) { uint8_t received = 0; - if (serial1.rxByte(received)) + while (!serial1.peek(received)) + ; + + { + serial1 << F("Peeked: "); serial1.txByte(received); + serial1 << F("\r\n"); + } + + if (serial1.rxByte(received)) { + serial1 << F("Received: "); + serial1.txByte(received); + serial1 << F("\r\n"); + } } _delay_ms(1000); diff --git a/uart/uart b/uart/uart index 0bfd303..a3d76a1 160000 --- a/uart/uart +++ b/uart/uart @@ -1 +1 @@ -Subproject commit 0bfd303a26a8aad77607e9cefb1039997952af09 +Subproject commit a3d76a138ddb9e5c0e7607aae38248ef0b33959b