From 866868b25fcde7ca936a59e2830508235603feb7 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Thu, 8 Jul 2021 11:21:27 +0200 Subject: [PATCH 1/3] uart support to read all available bytes --- linux/uart/UartComIF.cpp | 12 ++++++------ linux/uart/UartCookie.cpp | 8 ++++++++ linux/uart/UartCookie.h | 9 +++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/linux/uart/UartComIF.cpp b/linux/uart/UartComIF.cpp index eb12dee..56f4949 100644 --- a/linux/uart/UartComIF.cpp +++ b/linux/uart/UartComIF.cpp @@ -403,13 +403,13 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie &uartCookie, UartDevi return RETURN_FAILED; } else if (bytesRead != static_cast(requestLen)) { - sif::debug << "UartComIF::requestReceiveMessage: Only read " << bytesRead << - " of " << requestLen << " bytes" << std::endl; - return RETURN_FAILED; - } - else { - iter->second.replyLen = bytesRead; + if(uartCookie.isReplySizeFixed()) { + sif::debug << "UartComIF::requestReceiveMessage: Only read " << bytesRead << + " of " << requestLen << " bytes" << std::endl; + return RETURN_FAILED; + } } + iter->second.replyLen = bytesRead; return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/uart/UartCookie.cpp b/linux/uart/UartCookie.cpp index bfd815e..2e9cede 100644 --- a/linux/uart/UartCookie.cpp +++ b/linux/uart/UartCookie.cpp @@ -87,3 +87,11 @@ bool UartCookie::getInputShouldBeFlushed() { object_id_t UartCookie::getHandlerId() const { return this->handlerId; } + +void UartCookie::setNoFixedSizeReply() { + replySizeFixed = false; +} + +bool UartCookie::isReplySizeFixed() { + return replySizeFixed; +} diff --git a/linux/uart/UartCookie.h b/linux/uart/UartCookie.h index 69f59a5..faf95d5 100644 --- a/linux/uart/UartCookie.h +++ b/linux/uart/UartCookie.h @@ -95,6 +95,14 @@ public: void setTwoStopBits(); void setOneStopBit(); + /** + * Calling this function prevents the UartComIF to return failed if not all requested bytes + * could be read. This is required by a device handler when the size of a reply is not known. + */ + void setNoFixedSizeReply(); + + bool isReplySizeFixed(); + private: const object_id_t handlerId; @@ -107,6 +115,7 @@ private: uint8_t bitsPerWord = 8; uint8_t readCycles = 1; StopBits stopBits = StopBits::ONE_STOP_BIT; + bool replySizeFixed = true; }; #endif -- 2.34.1 From 323008c64a828028fee358de64f9782bb1fb5a33 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Sun, 11 Jul 2021 13:29:05 +0200 Subject: [PATCH 2/3] added setUartMode in configuration function --- linux/uart/UartComIF.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/uart/UartComIF.cpp b/linux/uart/UartComIF.cpp index 56f4949..6a126fa 100644 --- a/linux/uart/UartComIF.cpp +++ b/linux/uart/UartComIF.cpp @@ -79,6 +79,7 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { setStopBitOptions(&options, uartCookie); setDatasizeOptions(&options, uartCookie); setFixedOptions(&options); + setUartMode(&options, *uartCookie); if(uartCookie->getInputShouldBeFlushed()) { tcflush(fd, TCIFLUSH); } -- 2.34.1 From 88769bb46c34917f49c1d93abb0b1894b934b32c Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Mon, 12 Jul 2021 20:16:45 +0200 Subject: [PATCH 3/3] replaced sif::debug by sif::warning --- linux/uart/UartComIF.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/uart/UartComIF.cpp b/linux/uart/UartComIF.cpp index 6a126fa..c84affa 100644 --- a/linux/uart/UartComIF.cpp +++ b/linux/uart/UartComIF.cpp @@ -405,7 +405,7 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie &uartCookie, UartDevi } else if (bytesRead != static_cast(requestLen)) { if(uartCookie.isReplySizeFixed()) { - sif::debug << "UartComIF::requestReceiveMessage: Only read " << bytesRead << + sif::warning << "UartComIF::requestReceiveMessage: Only read " << bytesRead << " of " << requestLen << " bytes" << std::endl; return RETURN_FAILED; } -- 2.34.1