uart flush function
This commit is contained in:
parent
a7a4e0f219
commit
b83259592a
@ -443,6 +443,51 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF *cookie,
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF *cookie) {
|
||||||
|
std::string deviceFile;
|
||||||
|
UartDeviceMapIter uartDeviceMapIter;
|
||||||
|
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||||
|
if(uartCookie == nullptr) {
|
||||||
|
sif::warning << "UartComIF::flushUartRxBuffer: Invalid uart cookie!" << std::endl;
|
||||||
|
return NULLPOINTER;
|
||||||
|
}
|
||||||
|
deviceFile = uartCookie->getDeviceFile();
|
||||||
|
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
||||||
|
int fd = uartDeviceMapIter->second.fileDescriptor;
|
||||||
|
tcflush(fd, TCIFLUSH);
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF *cookie) {
|
||||||
|
std::string deviceFile;
|
||||||
|
UartDeviceMapIter uartDeviceMapIter;
|
||||||
|
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||||
|
if(uartCookie == nullptr) {
|
||||||
|
sif::warning << "UartComIF::flushUartTxBuffer: Invalid uart cookie!" << std::endl;
|
||||||
|
return NULLPOINTER;
|
||||||
|
}
|
||||||
|
deviceFile = uartCookie->getDeviceFile();
|
||||||
|
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
||||||
|
int fd = uartDeviceMapIter->second.fileDescriptor;
|
||||||
|
tcflush(fd, TCOFLUSH);
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF *cookie) {
|
||||||
|
std::string deviceFile;
|
||||||
|
UartDeviceMapIter uartDeviceMapIter;
|
||||||
|
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||||
|
if(uartCookie == nullptr) {
|
||||||
|
sif::warning << "UartComIF::flushUartTxAndRxBuf: Invalid uart cookie!" << std::endl;
|
||||||
|
return NULLPOINTER;
|
||||||
|
}
|
||||||
|
deviceFile = uartCookie->getDeviceFile();
|
||||||
|
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
||||||
|
int fd = uartDeviceMapIter->second.fileDescriptor;
|
||||||
|
tcflush(fd, TCIOFLUSH);
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
void UartComIF::setUartMode(struct termios *options, UartCookie &uartCookie) {
|
void UartComIF::setUartMode(struct termios *options, UartCookie &uartCookie) {
|
||||||
UartModes uartMode = uartCookie.getUartMode();
|
UartModes uartMode = uartCookie.getUartMode();
|
||||||
if(uartMode == UartModes::NON_CANONICAL) {
|
if(uartMode == UartModes::NON_CANONICAL) {
|
||||||
|
@ -41,6 +41,21 @@ public:
|
|||||||
ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||||
size_t *size) override;
|
size_t *size) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function discards all data received but not read in the UART buffer.
|
||||||
|
*/
|
||||||
|
ReturnValue_t flushUartRxBuffer(CookieIF *cookie);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function discards all data in the transmit buffer of the UART driver.
|
||||||
|
*/
|
||||||
|
ReturnValue_t flushUartTxBuffer(CookieIF *cookie);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function discards both data in the transmit and receive buffer of the UART.
|
||||||
|
*/
|
||||||
|
ReturnValue_t flushUartTxAndRxBuf(CookieIF *cookie);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
using UartDeviceFile_t = std::string;
|
using UartDeviceFile_t = std::string;
|
||||||
|
Loading…
Reference in New Issue
Block a user