added second reaction wheel

This commit is contained in:
Martin Zietz 2021-06-28 14:07:37 +02:00
parent 67f2ed83ce
commit c6655e50a0
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", auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_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 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, auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF,
gpioIds::EN_RW1); gpioIds::EN_RW1);
rwHandler1->setStartUpImmediately(); (void) rwHandler1;
// rwHandler1->setStartUpImmediately();
rw1SpiCookie->setCallbackArgs(rwHandler1); 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 */ #endif /* TE0720 == 0 */
new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); 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++; idx++;
} }
/** Sending frame start sign */ /** Sending frame end sign */
writeBuffer[0] = 0x7E; writeBuffer[0] = 0x7E;
writeSize = 1; writeSize = 1;
@ -155,7 +155,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s
/** Reached end of frame */ /** Reached end of frame */
break; break;
} }
else if (byteRead == 0xD) { else if (byteRead == 0x7D) {
if(read(fileDescriptor, &byteRead, 1) != 1) { if(read(fileDescriptor, &byteRead, 1) != 1) {
sif::error << "rwSpiCallback: Read failed" << std::endl; sif::error << "rwSpiCallback: Read failed" << std::endl;
result = RwHandler::SPI_READ_FAILURE; 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.6, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_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) { if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) {
sif::error << "SPI PST initialization failed" << std::endl; sif::error << "SPI PST initialization failed" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;

View File

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

View File

@ -98,17 +98,16 @@ private:
CommunicationStep communicationStep = CommunicationStep::READ_TEMPERATURE; CommunicationStep communicationStep = CommunicationStep::READ_TEMPERATURE;
enum class StartupStep { enum class StartupStep {
GET_RESET_STATUS, ENABLE_RW,
CLEAR_RESET_STATUS, CLEAR_RESET_STATUS,
INIT_RW INIT_RW,
STARTUP_COMPLETE
}; };
StartupStep startupStep = StartupStep::GET_RESET_STATUS; StartupStep startupStep = StartupStep::ENABLE_RW;
size_t sizeOfReply = 0; size_t sizeOfReply = 0;
bool startupPerformed = false;
/** /**
* @brief This function prepares the command to request the last reset status * @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 uint32_t LAST_RESET_ID = GET_LAST_RESET_STATUS;
static const size_t SIZE_GET_RESET_STATUS = 5; 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_GET_RW_STATUS = 14;
static const size_t SIZE_SET_SPEED_REPLY = 4; static const size_t SIZE_SET_SPEED_REPLY = 4;
static const size_t SIZE_GET_TEMPERATURE_REPLY = 8; static const size_t SIZE_GET_TEMPERATURE_REPLY = 8;

2
tmtc

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