15 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
2e243e3b29 Merge branch 'master' into meier/master 2021-06-24 17:26:09 +02:00
Martin Zietz
1e0e302308 callback gpio return code fix 2021-06-24 14:16:46 +02:00
cd41b6a1f2 Merge pull request 'UART: fixes for canonical mode' (#12) from mueller/master into master
Reviewed-on: #12
2021-06-24 10:41:23 +02:00
0f0fc0c2a6 Merge branch 'master' into mueller/master 2021-06-24 08:56:44 +02:00
2533af3b53 fixes for canonical mode 2021-06-24 08:49:45 +02:00
8fe5d0afa0 Merge branch 'master' into meier/master 2021-06-21 17:00:35 +02:00
fce40ebf9a Merge pull request 'UART ComIF update' (#11) from mueller/master into master
Reviewed-on: #11
2021-06-21 16:58:31 +02:00
37dff77d7e fixed merge conflict 2021-06-21 16:41:43 +02:00
7c23671433 Merge branch 'master' into meier/master 2021-06-21 16:33:08 +02:00
Martin Zietz
e3ddb8b3ba adaptions for spi callback 2021-06-21 14:49:20 +02:00
8 changed files with 44 additions and 18 deletions

View File

@@ -155,6 +155,7 @@ ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
}
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE,
1, gpioCallback->callbackArgs);
return RETURN_OK;
}
return GPIO_TYPE_FAILURE;
}
@@ -176,6 +177,7 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
}
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE,
0, gpioCallback->callbackArgs);
return RETURN_OK;
}
return GPIO_TYPE_FAILURE;
}

View File

@@ -147,7 +147,6 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF *cookie,
uint8_t* replyBuffer = i2cDeviceMapIter->second.replyBuffer.data();
int readLen = read(fd, replyBuffer, requestLen);
if (readLen != static_cast<int>(requestLen)) {
#if FSFW_VERBOSE_LEVEL >= 1 and FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::requestReceiveMessage: Reading from I2C "
@@ -157,6 +156,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF *cookie,
<< requestLen << " bytes" << std::endl;
#endif
i2cDeviceMapIter->second.replyLen = 0;
sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen << " bytes" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}

View File

@@ -64,6 +64,8 @@ public:
void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed);
void performSpiWiretapping(SpiCookie* spiCookie);
ReturnValue_t getReadBuffer(address_t spiAddress, uint8_t** buffer);
private:
struct SpiInstance {
@@ -83,8 +85,6 @@ private:
SpiDeviceMap spiDeviceMap;
ReturnValue_t performHalfDuplexReception(SpiCookie* spiCookie);
ReturnValue_t getReadBuffer(address_t spiAddress, uint8_t** buffer);
};
#endif /* LINUX_SPI_SPICOMIF_H_ */

View File

@@ -105,6 +105,10 @@ void SpiCookie::setCallbackMode(spi::send_callback_function_t callback,
this->callbackArgs = args;
}
void SpiCookie::setCallbackArgs(void *args) {
this->callbackArgs = args;
}
spi_ioc_transfer* SpiCookie::getTransferStructHandle() {
return &spiTransferStruct;
}

View File

@@ -75,6 +75,12 @@ public:
*/
void setCallbackMode(spi::send_callback_function_t callback, void* args);
/**
* Can be used to set the callback arguments and a later point than initialization.
* @param args
*/
void setCallbackArgs(void* args);
/**
* True if SPI transfers should be performed in full duplex mode
* @return

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);
}
@@ -305,10 +306,6 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF *cookie, size_t requestL
std::string deviceFile;
UartDeviceMapIter uartDeviceMapIter;
if(requestLen == 0) {
return RETURN_OK;
}
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
if(uartCookie == nullptr) {
sif::debug << "UartComIF::requestReceiveMessage: Invalid Uart Cookie!" << std::endl;
@@ -318,6 +315,11 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF *cookie, size_t requestL
UartModes uartMode = uartCookie->getUartMode();
deviceFile = uartCookie->getDeviceFile();
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
if(uartMode == UartModes::NON_CANONICAL and requestLen == 0) {
return RETURN_OK;
}
if (uartDeviceMapIter == uartDeviceMap.end()) {
sif::debug << "UartComIF::requestReceiveMessage: Device file " << deviceFile
<< " not in uart map" << std::endl;
@@ -370,11 +372,6 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
if (bytesRead < 0) {
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 if(bytesRead > 0) {
iter->second.replyLen += bytesRead;
bufferPtr += bytesRead;
@@ -407,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