5 Commits

Author SHA1 Message Date
Jakob.Meier
88769bb46c replaced sif::debug by sif::warning 2021-07-12 20:16:45 +02:00
Jakob.Meier
9c98f41a96 Merge branch 'master' of https://egit.irs.uni-stuttgart.de/fsfw/fsfw-hal into meier/master 2021-07-11 13:29:29 +02:00
Jakob.Meier
323008c64a added setUartMode in configuration function 2021-07-11 13:29:05 +02:00
Jakob.Meier
866868b25f uart support to read all available bytes 2021-07-08 11:21:27 +02:00
8ff09c95a6 Merge pull request 'meier/master' (#13) from meier/master into master
Reviewed-on: #13
2021-06-24 17:31:52 +02:00
3 changed files with 24 additions and 6 deletions

View File

@@ -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);
}
@@ -403,13 +404,13 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie &uartCookie, UartDevi
return RETURN_FAILED;
}
else if (bytesRead != static_cast<int>(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::warning << "UartComIF::requestReceiveMessage: Only read " << bytesRead <<
" of " << requestLen << " bytes" << std::endl;
return RETURN_FAILED;
}
}
iter->second.replyLen = bytesRead;
return HasReturnvaluesIF::RETURN_OK;
}

View File

@@ -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;
}

View File

@@ -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