meier/ReactionWheelHandler #51

Merged
muellerr merged 37 commits from meier/ReactionWheelHandler into develop 2021-07-05 15:40:42 +02:00
6 changed files with 42 additions and 9 deletions
Showing only changes of commit 428ae97e0e - Show all commits

View File

@ -548,13 +548,20 @@ void ObjectFactory::produce(void* args){
UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), 115200, UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), 115200,
PLOC::MAX_REPLY_SIZE); PLOC::MAX_REPLY_SIZE);
PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie);
GpioCookie* gpioCookieRw = new GpioCookie;
GpiodRegular* rw1ChipSelect = new GpiodRegular(std::string("gpiochip5"), 7,
std::string("Chip Select RW 1"), gpio::OUT, 1);
gpioCookieRw->addGpio(gpioIds::RW1, rw1ChipSelect);
gpioComIF->addGpios(gpioCookieRw);
auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::RW1, "/dev/spidev2.0", auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::RW1, "/dev/spidev2.0",
RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr);
auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie); auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie);
rwHandler1->setStartUpImmediately(); rwHandler1->setStartUpImmediately();
rw1SpiCookie->setCallbackArgs(rwHandler1);
#endif /* TE0720 == 0 */ #endif /* TE0720 == 0 */

View File

@ -103,6 +103,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s
} }
return RwHandler::SPI_WRITE_FAILURE; return RwHandler::SPI_WRITE_FAILURE;
} }
idx++;
} }
/** Sending frame start sign */ /** Sending frame start sign */
@ -125,6 +126,14 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s
uint8_t* rxBuf = nullptr; uint8_t* rxBuf = nullptr;
result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
if(gpioId != gpio::NO_GPIO) {
if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) {
sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl;
}
}
if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) {
sif::error << "rwSpiCallback: Failed to unlock mutex";
}
return result; return result;
} }
@ -133,6 +142,14 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s
uint8_t byteRead = 0; uint8_t byteRead = 0;
/** Reading the reply frame */ /** Reading the reply frame */
if(read(fileDescriptor, &byteRead, 1) != 1) { if(read(fileDescriptor, &byteRead, 1) != 1) {
if(gpioId != gpio::NO_GPIO) {
if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) {
sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl;
}
}
if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) {
sif::error << "rwSpiCallback: Failed to unlock mutex";
}
sif::error << "rwSpiCallback: Failed to read first byte of reply frame" << std::endl; sif::error << "rwSpiCallback: Failed to read first byte of reply frame" << std::endl;
return RwHandler::SPI_READ_FAILURE; return RwHandler::SPI_READ_FAILURE;
} }
@ -140,6 +157,14 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s
/** First byte must be the start sign 0x7E */ /** First byte must be the start sign 0x7E */
if (byteRead != 0x7E) { if (byteRead != 0x7E) {
sif::error << "rwSpiCallback: First byte of reply is not 0x7E" << std::endl; sif::error << "rwSpiCallback: First byte of reply is not 0x7E" << std::endl;
if(gpioId != gpio::NO_GPIO) {
if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) {
sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl;
}
}
if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) {
sif::error << "rwSpiCallback: Failed to unlock mutex";
}
return RwHandler::MISSING_START_SIGN; return RwHandler::MISSING_START_SIGN;
} }

View File

@ -412,6 +412,12 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence)
// thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); // thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ);
// thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); // thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::RW1, length * 0.4, DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::RW1, length * 0.6, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ);
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -480,8 +486,9 @@ ReturnValue_t pst::gomspacePstInit(FixedTimeslotTaskIF *thisSequence){
ReturnValue_t pst::pollingSequenceTest(FixedTimeslotTaskIF* thisSequence) { ReturnValue_t pst::pollingSequenceTest(FixedTimeslotTaskIF* thisSequence) {
/* Length of a communication cycle */ /* Length of a communication cycle */
uint32_t length = thisSequence->getPeriodMs();
#if OBSW_ADD_ACS_BOARD == 1 #if OBSW_ADD_ACS_BOARD == 1
uint32_t length = thisSequence->getPeriodMs();
thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0,
DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2,

View File

@ -3,7 +3,6 @@
#include <fsfw/globalfunctions/CRC.h> #include <fsfw/globalfunctions/CRC.h>
#include <fsfw/datapool/PoolReadGuard.h> #include <fsfw/datapool/PoolReadGuard.h>
#include <math.h>
RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) :
DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), statusSet(this) { DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), statusSet(this) {

View File

@ -21,11 +21,6 @@ public:
RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
virtual ~RwHandler(); virtual ~RwHandler();
/**
* @brief Sets mode to MODE_NORMAL. Can be used for debugging.
*/
void setModeNormal();
static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER;
static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0);

2
tmtc

@ -1 +1 @@
Subproject commit 805470df6d907ba5002fcca1ae71f662a7097b0b Subproject commit 7a4d6ee13a32119a9a9e815d32680ae7ab302699