Compare commits
15 Commits
fe661fff85
...
meier/mast
Author | SHA1 | Date | |
---|---|---|---|
![]() |
88769bb46c | ||
![]() |
9c98f41a96 | ||
![]() |
323008c64a | ||
![]() |
866868b25f | ||
8ff09c95a6 | |||
2e243e3b29 | |||
![]() |
1e0e302308 | ||
cd41b6a1f2 | |||
0f0fc0c2a6 | |||
2533af3b53 | |||
8fe5d0afa0 | |||
fce40ebf9a | |||
37dff77d7e | |||
7c23671433 | |||
![]() |
e3ddb8b3ba |
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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_ */
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user