From e3ddb8b3badab7077a5e2fcc315eac17a319d5c7 Mon Sep 17 00:00:00 2001 From: Martin Zietz Date: Mon, 21 Jun 2021 14:49:20 +0200 Subject: [PATCH 1/3] adaptions for spi callback --- linux/i2c/I2cComIF.cpp | 5 +++++ linux/spi/SpiComIF.h | 4 ++-- linux/spi/SpiCookie.cpp | 4 ++++ linux/spi/SpiCookie.h | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/linux/i2c/I2cComIF.cpp b/linux/i2c/I2cComIF.cpp index a88b019..7abcd2c 100644 --- a/linux/i2c/I2cComIF.cpp +++ b/linux/i2c/I2cComIF.cpp @@ -147,9 +147,13 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF *cookie, uint8_t* replyBuffer = i2cDeviceMapIter->second.replyBuffer.data(); int readLen = read(fd, replyBuffer, requestLen); +<<<<<<< Updated upstream if (readLen != static_cast(requestLen)) { #if FSFW_VERBOSE_LEVEL >= 1 and FSFW_CPP_OSTREAM_ENABLED == 1 +======= + if (readLen != static_cast(requestLen)) { +>>>>>>> Stashed changes sif::error << "I2cComIF::requestReceiveMessage: Reading from I2C " << "device failed with error code " << errno <<". Description" << " of error: " << strerror(errno) << std::endl; @@ -157,6 +161,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; } diff --git a/linux/spi/SpiComIF.h b/linux/spi/SpiComIF.h index 13f7603..676c7cb 100644 --- a/linux/spi/SpiComIF.h +++ b/linux/spi/SpiComIF.h @@ -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_ */ diff --git a/linux/spi/SpiCookie.cpp b/linux/spi/SpiCookie.cpp index 15ba3e9..e34ea36 100644 --- a/linux/spi/SpiCookie.cpp +++ b/linux/spi/SpiCookie.cpp @@ -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; } diff --git a/linux/spi/SpiCookie.h b/linux/spi/SpiCookie.h index 174ca9e..acf7c77 100644 --- a/linux/spi/SpiCookie.h +++ b/linux/spi/SpiCookie.h @@ -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 -- 2.43.0 From 37dff77d7ec85eefef241e9107ae41ae520dddf6 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Mon, 21 Jun 2021 16:41:43 +0200 Subject: [PATCH 2/3] fixed merge conflict --- linux/i2c/I2cComIF.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/linux/i2c/I2cComIF.cpp b/linux/i2c/I2cComIF.cpp index 7abcd2c..aa336c7 100644 --- a/linux/i2c/I2cComIF.cpp +++ b/linux/i2c/I2cComIF.cpp @@ -147,13 +147,8 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF *cookie, uint8_t* replyBuffer = i2cDeviceMapIter->second.replyBuffer.data(); int readLen = read(fd, replyBuffer, requestLen); -<<<<<<< Updated upstream - if (readLen != static_cast(requestLen)) { #if FSFW_VERBOSE_LEVEL >= 1 and FSFW_CPP_OSTREAM_ENABLED == 1 -======= - if (readLen != static_cast(requestLen)) { ->>>>>>> Stashed changes sif::error << "I2cComIF::requestReceiveMessage: Reading from I2C " << "device failed with error code " << errno <<". Description" << " of error: " << strerror(errno) << std::endl; -- 2.43.0 From 1e0e302308cebdb00cb53ae6bd2e79dad2c3a3e5 Mon Sep 17 00:00:00 2001 From: Martin Zietz Date: Thu, 24 Jun 2021 14:16:46 +0200 Subject: [PATCH 3/3] callback gpio return code fix --- linux/gpio/LinuxLibgpioIF.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux/gpio/LinuxLibgpioIF.cpp b/linux/gpio/LinuxLibgpioIF.cpp index 2a645fc..cfdac2b 100644 --- a/linux/gpio/LinuxLibgpioIF.cpp +++ b/linux/gpio/LinuxLibgpioIF.cpp @@ -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; } -- 2.43.0