this should fix some bugs
This commit is contained in:
parent
677457bbe7
commit
8d4b980c32
@ -538,7 +538,7 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction
|
||||
|
||||
FixedTimeslotTaskIF* gomSpacePstTask =
|
||||
factory.createFixedTimeslotTask("GS_PST_TASK", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4,
|
||||
0.5, missedDeadlineFunc, &RR_SCHEDULING);
|
||||
0.25, missedDeadlineFunc, &RR_SCHEDULING);
|
||||
result = pst::pstGompaceCan(gomSpacePstTask);
|
||||
if (result != returnvalue::OK) {
|
||||
if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
|
||||
|
@ -21,15 +21,14 @@ SyrlinksHandler::~SyrlinksHandler() = default;
|
||||
|
||||
void SyrlinksHandler::doStartUp() {
|
||||
if (internalState == InternalState::OFF) {
|
||||
transitionCommandPending = false;
|
||||
internalState = InternalState::ENABLE_TEMPERATURE_PROTECTION;
|
||||
commandExecuted = false;
|
||||
}
|
||||
if (internalState == InternalState::ENABLE_TEMPERATURE_PROTECTION) {
|
||||
if (commandExecuted) {
|
||||
// Go to normal mode immediately and disable transmitter on startup.
|
||||
setMode(_MODE_TO_NORMAL);
|
||||
internalState = InternalState::IDLE;
|
||||
setMode(_MODE_TO_ON);
|
||||
internalState = InternalState::TX_TRANSITION;
|
||||
commandExecuted = false;
|
||||
}
|
||||
}
|
||||
@ -37,15 +36,16 @@ void SyrlinksHandler::doStartUp() {
|
||||
|
||||
void SyrlinksHandler::doShutDown() {
|
||||
// In any case, always disable TX first.
|
||||
if (internalState != InternalState::SET_TX_STANDBY) {
|
||||
internalState = InternalState::SET_TX_STANDBY;
|
||||
transitionCommandPending = false;
|
||||
if (internalState != InternalState::TX_TRANSITION) {
|
||||
internalState = InternalState::TX_TRANSITION;
|
||||
transState = TransitionState::SET_TX_STANDBY;
|
||||
commandExecuted = false;
|
||||
}
|
||||
if (internalState == InternalState::SET_TX_STANDBY) {
|
||||
if (internalState == InternalState::TX_TRANSITION) {
|
||||
if (commandExecuted) {
|
||||
temperatureSet.setValidity(false, true);
|
||||
internalState = InternalState::OFF;
|
||||
transState = TransitionState::IDLE;
|
||||
commandExecuted = false;
|
||||
setMode(_MODE_POWER_DOWN);
|
||||
}
|
||||
@ -104,23 +104,25 @@ ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* i
|
||||
*id = syrlinks::WRITE_LCL_CONFIG;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
case InternalState::SET_TX_MODULATION: {
|
||||
case InternalState::TX_TRANSITION: {
|
||||
switch (transState) {
|
||||
case TransitionState::SET_TX_MODULATION: {
|
||||
*id = syrlinks::SET_TX_MODE_MODULATION;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
case InternalState::SELECT_MODULATION_BPSK: {
|
||||
case TransitionState::SELECT_MODULATION_BPSK: {
|
||||
*id = syrlinks::SET_WAVEFORM_BPSK;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
case InternalState::SELECT_MODULATION_0QPSK: {
|
||||
case TransitionState::SELECT_MODULATION_0QPSK: {
|
||||
*id = syrlinks::SET_WAVEFORM_0QPSK;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
case InternalState::SET_TX_CW: {
|
||||
case TransitionState::SET_TX_CW: {
|
||||
*id = syrlinks::SET_TX_MODE_CW;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
case InternalState::SET_TX_STANDBY: {
|
||||
case TransitionState::SET_TX_STANDBY: {
|
||||
*id = syrlinks::SET_TX_MODE_STANDBY;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
@ -128,6 +130,11 @@ ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* i
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
@ -675,12 +682,31 @@ ReturnValue_t SyrlinksHandler::handleAckReply(const uint8_t* packet) {
|
||||
break;
|
||||
}
|
||||
case (syrlinks::SET_WAVEFORM_BPSK):
|
||||
case (syrlinks::SET_WAVEFORM_0QPSK):
|
||||
case (syrlinks::SET_TX_MODE_STANDBY):
|
||||
case (syrlinks::SET_TX_MODE_MODULATION):
|
||||
case (syrlinks::SET_WAVEFORM_0QPSK): {
|
||||
if (result == returnvalue::OK and isTransitionalMode()) {
|
||||
transState = TransitionState::SET_TX_MODULATION;
|
||||
commandExecuted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (syrlinks::SET_TX_MODE_STANDBY): {
|
||||
if (result == returnvalue::OK and isTransitionalMode()) {
|
||||
transState = TransitionState::DONE;
|
||||
commandExecuted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (syrlinks::SET_TX_MODE_MODULATION): {
|
||||
if (result == returnvalue::OK and isTransitionalMode()) {
|
||||
transState = TransitionState::DONE;
|
||||
commandExecuted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (syrlinks::SET_TX_MODE_CW): {
|
||||
if (result == returnvalue::OK and isTransitionalMode()) {
|
||||
commandExecuted = true;
|
||||
transState = TransitionState::DONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -731,77 +757,41 @@ void SyrlinksHandler::setDebugMode(bool enable) { this->debugMode = enable; }
|
||||
|
||||
void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||
Mode_t tgtMode = getBaseMode(getMode());
|
||||
auto commandDone = [&]() {
|
||||
if (transState == TransitionState::DONE) {
|
||||
setMode(tgtMode);
|
||||
transitionCommandPending = false;
|
||||
internalState = InternalState::IDLE;
|
||||
};
|
||||
auto txOnHandler = [&](InternalState selMod) {
|
||||
txDataset.setReportingEnabled(true);
|
||||
poolManager.changeCollectionInterval(txDataset.getSid(), 10.0);
|
||||
poolManager.changeCollectionInterval(temperatureSet.getSid(), 5.0);
|
||||
if (internalState == InternalState::IDLE) {
|
||||
transitionCommandPending = false;
|
||||
commandExecuted = false;
|
||||
internalState = selMod;
|
||||
transState = TransitionState::IDLE;
|
||||
return;
|
||||
}
|
||||
// Select modulation first (BPSK or 0QPSK).
|
||||
if (internalState == selMod) {
|
||||
if (commandExecuted) {
|
||||
transitionCommandPending = false;
|
||||
internalState = InternalState::SET_TX_MODULATION;
|
||||
commandExecuted = false;
|
||||
}
|
||||
}
|
||||
// Now go into modulation mode.
|
||||
if (internalState == InternalState::SET_TX_MODULATION) {
|
||||
if (commandExecuted) {
|
||||
commandDone();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
auto txStandbyHandler = [&]() {
|
||||
txDataset.setReportingEnabled(false);
|
||||
poolManager.changeCollectionInterval(temperatureSet.getSid(), 60.0);
|
||||
if (internalState == InternalState::IDLE) {
|
||||
transitionCommandPending = false;
|
||||
internalState = InternalState::SET_TX_STANDBY;
|
||||
commandExecuted = false;
|
||||
}
|
||||
if (internalState == InternalState::SET_TX_STANDBY) {
|
||||
if (commandExecuted) {
|
||||
commandDone();
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
auto txOnHandler = [&]() {
|
||||
txDataset.setReportingEnabled(true);
|
||||
poolManager.changeCollectionInterval(txDataset.getSid(), 10.0);
|
||||
poolManager.changeCollectionInterval(temperatureSet.getSid(), 5.0);
|
||||
};
|
||||
if (tgtMode == HasModesIF::MODE_ON or tgtMode == DeviceHandlerIF::MODE_NORMAL) {
|
||||
switch (getSubmode()) {
|
||||
case (com::Submode::RX_AND_TX_DEFAULT_DATARATE): {
|
||||
auto currentDatarate = com::getCurrentDatarate();
|
||||
txOnHandler();
|
||||
if (currentDatarate == com::Datarate::LOW_RATE_MODULATION_BPSK) {
|
||||
if (txOnHandler(InternalState::SELECT_MODULATION_BPSK)) {
|
||||
return;
|
||||
}
|
||||
transState = TransitionState::SELECT_MODULATION_BPSK;
|
||||
} else if (currentDatarate == com::Datarate::HIGH_RATE_MODULATION_0QPSK) {
|
||||
if (txOnHandler(InternalState::SELECT_MODULATION_0QPSK)) {
|
||||
return;
|
||||
}
|
||||
transState = TransitionState::SELECT_MODULATION_0QPSK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (com::Submode::RX_AND_TX_LOW_DATARATE): {
|
||||
if (txOnHandler(InternalState::SELECT_MODULATION_BPSK)) {
|
||||
return;
|
||||
}
|
||||
txOnHandler();
|
||||
transState = TransitionState::SELECT_MODULATION_BPSK;
|
||||
break;
|
||||
}
|
||||
case (com::Submode::RX_AND_TX_HIGH_DATARATE): {
|
||||
if (txOnHandler(InternalState::SELECT_MODULATION_0QPSK)) {
|
||||
return;
|
||||
}
|
||||
txOnHandler();
|
||||
transState = TransitionState::SELECT_MODULATION_0QPSK;
|
||||
break;
|
||||
}
|
||||
case (com::Submode::RX_ONLY): {
|
||||
@ -809,21 +799,16 @@ void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||
return;
|
||||
}
|
||||
case (com::Submode::RX_AND_TX_CW): {
|
||||
if (internalState == InternalState::IDLE) {
|
||||
internalState = InternalState::SET_TX_STANDBY;
|
||||
commandExecuted = false;
|
||||
}
|
||||
if (commandExecuted) {
|
||||
commandDone();
|
||||
return;
|
||||
}
|
||||
txOnHandler();
|
||||
transState = TransitionState::SET_TX_CW;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
commandDone();
|
||||
DeviceHandlerBase::doTransition(modeFrom, subModeFrom);
|
||||
}
|
||||
}
|
||||
} else if (tgtMode == HasModesIF::MODE_OFF) {
|
||||
txStandbyHandler();
|
||||
transState = TransitionState::SET_TX_STANDBY;
|
||||
}
|
||||
}
|
||||
|
@ -112,22 +112,25 @@ class SyrlinksHandler : public DeviceHandlerBase {
|
||||
float tempPowerAmplifier = 0;
|
||||
float tempBasebandBoard = 0;
|
||||
bool commandExecuted = false;
|
||||
bool transitionCommandPending = false;
|
||||
|
||||
uint8_t commandBuffer[syrlinks::MAX_COMMAND_SIZE];
|
||||
|
||||
enum class InternalState {
|
||||
OFF,
|
||||
ENABLE_TEMPERATURE_PROTECTION,
|
||||
TX_TRANSITION,
|
||||
IDLE
|
||||
} internalState = InternalState::OFF;
|
||||
|
||||
enum class TransitionState {
|
||||
IDLE,
|
||||
SELECT_MODULATION_BPSK,
|
||||
SELECT_MODULATION_0QPSK,
|
||||
SET_TX_MODULATION,
|
||||
SET_TX_CW,
|
||||
SET_TX_STANDBY,
|
||||
IDLE
|
||||
};
|
||||
|
||||
InternalState internalState = InternalState::OFF;
|
||||
DONE
|
||||
} transState = TransitionState::IDLE;
|
||||
|
||||
/**
|
||||
* This object is used to store the id of the next command to execute. This controls the
|
||||
|
@ -26,8 +26,7 @@ ReturnValue_t pst::pstSyrlinks(FixedTimeslotTaskIF *thisSequence) {
|
||||
thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.25, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.25, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.4,
|
||||
DeviceHandlerIF::PERFORM_OPERATION);
|
||||
|
||||
thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.4, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ);
|
||||
@ -119,35 +118,10 @@ ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) {
|
||||
thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.25, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::ACU_HANDLER, length * 0.25, DeviceHandlerIF::SEND_READ);
|
||||
|
||||
thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.25, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.25, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.25, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::ACU_HANDLER, length * 0.25, DeviceHandlerIF::GET_READ);
|
||||
|
||||
thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.5, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
|
||||
thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.5, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::SEND_WRITE);
|
||||
|
||||
thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.5, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::GET_WRITE);
|
||||
|
||||
thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::ACU_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ);
|
||||
|
||||
thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.75, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.75, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.75, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::ACU_HANDLER, length * 0.75, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ);
|
||||
if (thisSequence->checkSequence() != returnvalue::OK) {
|
||||
sif::error << "GomSpace PST initialization failed" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
|
Loading…
Reference in New Issue
Block a user