added second reaction wheel

This commit is contained in:
Martin Zietz 2021-06-28 14:07:37 +02:00
parent 516ef34b21
commit 23731e367c
7 changed files with 76 additions and 30 deletions

View File

@ -582,12 +582,26 @@ void ObjectFactory::produce(void* args){
auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, "/dev/spidev2.0",
RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr);
auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, "/dev/spidev2.0",
RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr);
auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, "/dev/spidev2.0",
RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr);
auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, "/dev/spidev2.0",
RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr);
(void) rw3SpiCookie;
(void) rw4SpiCookie;
auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF,
gpioIds::EN_RW1);
rwHandler1->setStartUpImmediately();
(void) rwHandler1;
// rwHandler1->setStartUpImmediately();
rw1SpiCookie->setCallbackArgs(rwHandler1);
auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF,
gpioIds::EN_RW1);
rwHandler2->setStartUpImmediately();
rw2SpiCookie->setCallbackArgs(rwHandler2);
#endif /* TE0720 == 0 */
new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);

View File

@ -93,7 +93,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s
idx++;
}
/** Sending frame start sign */
/** Sending frame end sign */
writeBuffer[0] = 0x7E;
writeSize = 1;
@ -155,7 +155,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s
/** Reached end of frame */
break;
}
else if (byteRead == 0xD) {
else if (byteRead == 0x7D) {
if(read(fileDescriptor, &byteRead, 1) != 1) {
sif::error << "rwSpiCallback: Read failed" << std::endl;
result = RwHandler::SPI_READ_FAILURE;

View File

@ -407,6 +407,12 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
thisSequence->addSlot(objects::RW1, length * 0.6, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::RW2, length * 0.4, DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::RW2, length * 0.6, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ);
if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) {
sif::error << "SPI PST initialization failed" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;

View File

@ -20,12 +20,19 @@ RwHandler::~RwHandler() {
}
void RwHandler::doStartUp() {
if (!startupPerformed) {
return;
}
if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) {
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high";
switch (startupStep) {
case StartupStep::ENABLE_RW: {
if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) {
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high";
}
return;
}
case StartupStep::STARTUP_COMPLETE:
break;
default:
return;
}
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
setMode(MODE_NORMAL);
#else
@ -37,7 +44,8 @@ void RwHandler::doShutDown() {
if(gpioComIF->pullLow(enableGpio) != RETURN_OK) {
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low";
}
startupPerformed = false;
/** Reset startup step for next doStartUp routine */
startupStep = StartupStep::ENABLE_RW;
}
ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) {
@ -64,7 +72,7 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) {
ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) {
switch (startupStep) {
case StartupStep::GET_RESET_STATUS:
case StartupStep::ENABLE_RW:
*id = RwDefinitions::GET_LAST_RESET_STATUS;
startupStep = StartupStep::CLEAR_RESET_STATUS;
break;
@ -74,9 +82,10 @@ ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) {
break;
case StartupStep::INIT_RW:
*id = RwDefinitions::INIT_RW_CONTROLLER;
startupStep = StartupStep::GET_RESET_STATUS;
startupPerformed = true;
startupStep = StartupStep::STARTUP_COMPLETE;
break;
case StartupStep::STARTUP_COMPLETE:
break;
default:
sif::debug << "RwHandler::buildTransitionDeviceCommand: Invalid startup step"
<< std::endl;
@ -136,17 +145,19 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand
}
void RwHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(RwDefinitions::RESET_MCU);
this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet,
RwDefinitions::SIZE_GET_RESET_STATUS);
this->insertInCommandMap(RwDefinitions::CLEAR_LAST_RESET_STATUS);
this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet,
RwDefinitions::SIZE_GET_RW_STATUS);
this->insertInCommandMap(RwDefinitions::INIT_RW_CONTROLLER);
this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet,
RwDefinitions::SIZE_GET_TEMPERATURE_REPLY);
this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr,
RwDefinitions::SIZE_SET_SPEED_REPLY);
this->insertInCommandMap(RwDefinitions::RESET_MCU);
this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet,
RwDefinitions::SIZE_GET_RESET_STATUS);
this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr,
RwDefinitions::SIZE_CLEAR_RESET_STATUS);
this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet,
RwDefinitions::SIZE_GET_RW_STATUS);
this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr,
RwDefinitions::SIZE_INIT_RW);
this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet,
RwDefinitions::SIZE_GET_TEMPERATURE_REPLY);
this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr,
RwDefinitions::SIZE_SET_SPEED_REPLY);
}
ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize,
@ -158,11 +169,21 @@ ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize
*foundId = RwDefinitions::GET_LAST_RESET_STATUS;
break;
}
case (static_cast<uint8_t>(RwDefinitions::CLEAR_LAST_RESET_STATUS)): {
*foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS;
*foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS;
break;
}
case (static_cast<uint8_t>(RwDefinitions::GET_RW_STATUS)): {
*foundLen = RwDefinitions::SIZE_GET_RW_STATUS;
*foundId = RwDefinitions::GET_RW_STATUS;
break;
}
case (static_cast<uint8_t>(RwDefinitions::INIT_RW_CONTROLLER)): {
*foundLen = RwDefinitions::SIZE_INIT_RW;
*foundId = RwDefinitions::INIT_RW_CONTROLLER;
break;
}
case (static_cast<uint8_t>(RwDefinitions::SET_SPEED)): {
*foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY;
*foundId = RwDefinitions::SET_SPEED;
@ -189,6 +210,8 @@ ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_
/** Check result code */
if (*(packet + 1) == RwDefinitions::ERROR) {
sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: "
<< id << std::endl;
return EXECUTION_FAILED;
}
@ -209,6 +232,8 @@ ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_
handleGetRwStatusReply(packet);
break;
}
case (RwDefinitions::CLEAR_LAST_RESET_STATUS):
case (RwDefinitions::INIT_RW_CONTROLLER):
case (RwDefinitions::SET_SPEED):
// no reply data expected
break;
@ -230,7 +255,7 @@ void RwHandler::setNormalDatapoolEntriesInvalid() {
}
uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
return 5000;
return 15000;
}
ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,

View File

@ -98,17 +98,16 @@ private:
CommunicationStep communicationStep = CommunicationStep::READ_TEMPERATURE;
enum class StartupStep {
GET_RESET_STATUS,
ENABLE_RW,
CLEAR_RESET_STATUS,
INIT_RW
INIT_RW,
STARTUP_COMPLETE
};
StartupStep startupStep = StartupStep::GET_RESET_STATUS;
StartupStep startupStep = StartupStep::ENABLE_RW;
size_t sizeOfReply = 0;
bool startupPerformed = false;
/**
* @brief This function prepares the command to request the last reset status
*/

View File

@ -41,6 +41,8 @@ static const uint32_t STATUS_SET_ID = GET_RW_STATUS;
static const uint32_t LAST_RESET_ID = GET_LAST_RESET_STATUS;
static const size_t SIZE_GET_RESET_STATUS = 5;
static const size_t SIZE_CLEAR_RESET_STATUS = 4;
static const size_t SIZE_INIT_RW = 4;
static const size_t SIZE_GET_RW_STATUS = 14;
static const size_t SIZE_SET_SPEED_REPLY = 4;
static const size_t SIZE_GET_TEMPERATURE_REPLY = 8;

2
tmtc

@ -1 +1 @@
Subproject commit 899cd942ce7136f371e93d270a6c6c149c0698cb
Subproject commit 19b76d961c61966a0093d3768f62d99196e1c9b2