Two errors in the device handler to fix. Adjust the receiving of the packet in the 0.18s window and solve the problem of automatic passage to MODE OFf.
This commit is contained in:
parent
02bde1133e
commit
d366b3ca22
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -111,7 +111,7 @@ void InitMission::createTasks(){
|
||||
|
||||
FixedTimeslotTaskIF* arduinoTask = TaskFactory::instance()->
|
||||
createFixedTimeslotTask("ARDUINO_TASK",40,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 3.2, nullptr);
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, nullptr);
|
||||
result = pollingSequenceArduinoFunction(arduinoTask);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "InitMission::createTasks:ArduinoPST initialization failed!"
|
||||
@ -151,13 +151,13 @@ void InitMission::createTasks(){
|
||||
|
||||
//Main thread sleep
|
||||
sif::debug << "Starting Tasks in 3.2 seconds" << std::endl;
|
||||
TaskFactory::delayTask(3200);
|
||||
TaskFactory::delayTask(1600);
|
||||
distributerTask->startTask();
|
||||
udpBridgeTask->startTask();
|
||||
udpPollingTask->startTask();
|
||||
//serializeTask->startTask();
|
||||
//arduinoTask->startTask();
|
||||
controllerTask->startTask();
|
||||
arduinoTask->startTask();
|
||||
//controllerTask->startTask();
|
||||
|
||||
//payloadTask->startTask();
|
||||
eventTask->startTask();
|
||||
|
@ -78,6 +78,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
|
||||
performOperationHook();
|
||||
}
|
||||
if (mode == MODE_OFF) {
|
||||
sif::debug<<"DH_base: Mode off"<<std::endl;
|
||||
return RETURN_OK;
|
||||
}
|
||||
switch (getComAction()) {
|
||||
@ -293,6 +294,7 @@ void DeviceHandlerBase::doStateMachine() {
|
||||
}
|
||||
break;
|
||||
case _MODE_POWER_DOWN:
|
||||
sif::debug<<"DH_base: mode power down"<<std::endl;
|
||||
commandSwitch(PowerSwitchIF::SWITCH_OFF);
|
||||
setMode(_MODE_WAIT_OFF);
|
||||
break;
|
||||
@ -322,6 +324,7 @@ void DeviceHandlerBase::doStateMachine() {
|
||||
}
|
||||
break;
|
||||
case _MODE_WAIT_OFF: {
|
||||
sif::debug<<"DH_base: mode power down"<<std::endl;
|
||||
uint32_t currentUptime;
|
||||
Clock::getUptime(¤tUptime);
|
||||
|
||||
@ -358,6 +361,7 @@ void DeviceHandlerBase::doStateMachine() {
|
||||
break;
|
||||
default:
|
||||
triggerEvent(OBJECT_IN_INVALID_MODE, mode, submode);
|
||||
sif::debug<<"object in invalid mode"<<std::endl;
|
||||
setMode(_MODE_POWER_DOWN, 0);
|
||||
break;
|
||||
}
|
||||
@ -661,9 +665,10 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
|
||||
// scanForReply routines.
|
||||
uint32_t remainingLength = receivedDataLen;
|
||||
for (uint32_t count = 0; count < receivedDataLen; count++) {
|
||||
|
||||
sif::debug<<"DH_base: debug0"<<std::endl;
|
||||
result = scanForReply(receivedData, remainingLength, &foundId,
|
||||
&foundLen);
|
||||
sif::debug<<"DH_base: debug01"<<std::endl;
|
||||
switch (result) {
|
||||
case RETURN_OK:
|
||||
handleReply(receivedData, foundId, foundLen);
|
||||
@ -684,6 +689,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
|
||||
case IGNORE_FULL_PACKET:
|
||||
return;
|
||||
default:
|
||||
sif::debug<<"DH_base: debug02"<<std::endl;
|
||||
//We need to wait for timeout.. don't know what command failed and who sent it.
|
||||
replyRawReplyIfnotWiretapped(receivedData, foundLen);
|
||||
triggerEvent(DEVICE_READING_REPLY_FAILED, result, foundLen);
|
||||
@ -911,6 +917,7 @@ Mode_t DeviceHandlerBase::getBaseMode(Mode_t transitionMode) {
|
||||
return _MODE_TO_ON;
|
||||
}
|
||||
if (transitionMode == _MODE_SHUT_DOWN) {
|
||||
sif::debug<<"mode shut down"<<std::endl;
|
||||
return _MODE_POWER_DOWN;
|
||||
}
|
||||
return transitionMode
|
||||
|
@ -31,10 +31,13 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event)
|
||||
if(isFdirInActionOrAreWeFaulty(event)) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
sif::debug<<"DH_FDIR: event received"<<std::endl;
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
switch (event->getEvent()) {
|
||||
case HasModesIF::MODE_TRANSITION_FAILED:
|
||||
case HasModesIF::OBJECT_IN_INVALID_MODE:
|
||||
sif::debug<<"DH_FDIR: event received 1"<<std::endl;
|
||||
//We'll try a recovery as long as defined in MAX_REBOOT.
|
||||
//Might cause some AssemblyBase cycles, so keep number low.
|
||||
handleRecovery(event->getEvent());
|
||||
@ -44,6 +47,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event)
|
||||
case DeviceHandlerIF::DEVICE_UNREQUESTED_REPLY:
|
||||
case DeviceHandlerIF::DEVICE_UNKNOWN_REPLY: //Some DH's generate generic reply-ids.
|
||||
case DeviceHandlerIF::DEVICE_BUILDING_COMMAND_FAILED:
|
||||
sif::debug<<"DH_FDIR: event received 2"<<std::endl;
|
||||
//These faults all mean that there were stupid replies from a device.
|
||||
if (strangeReplyCount.incrementAndCheck()) {
|
||||
handleRecovery(event->getEvent());
|
||||
@ -53,6 +57,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event)
|
||||
case DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED:
|
||||
//The two above should never be confirmed.
|
||||
case DeviceHandlerIF::DEVICE_MISSED_REPLY:
|
||||
sif::debug<<"DH_FDIR: event received 3"<<std::endl;
|
||||
result = sendConfirmationRequest(event);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
break;
|
||||
@ -64,14 +69,17 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event)
|
||||
break;
|
||||
case StorageManagerIF::GET_DATA_FAILED:
|
||||
case StorageManagerIF::STORE_DATA_FAILED:
|
||||
sif::debug<<"DH_FDIR: event received 4"<<std::endl;
|
||||
//Rather strange bugs, occur in RAW mode only. Ignore.
|
||||
break;
|
||||
case DeviceHandlerIF::INVALID_DEVICE_COMMAND:
|
||||
sif::debug<<"DH_FDIR: event received 5"<<std::endl;
|
||||
//Ignore, is bad configuration. We can't do anything in flight.
|
||||
break;
|
||||
case HasHealthIF::HEALTH_INFO:
|
||||
case HasModesIF::MODE_INFO:
|
||||
case HasModesIF::CHANGING_MODE:
|
||||
sif::debug<<"DH_FDIR: event received 6"<<std::endl;
|
||||
//Do nothing, but mark as handled.
|
||||
break;
|
||||
//****Power*****
|
||||
@ -98,6 +106,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event)
|
||||
case ThermalComponentIF::COMPONENT_TEMP_HIGH:
|
||||
case ThermalComponentIF::COMPONENT_TEMP_OOL_LOW:
|
||||
case ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH:
|
||||
sif::debug<<"DH_FDIR: event received 7"<<std::endl;
|
||||
//Well, the device is not really faulty, but it is required to stay off as long as possible.
|
||||
setFaulty(event->getEvent());
|
||||
break;
|
||||
@ -228,6 +237,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::getParameter(uint8_t domainId,
|
||||
}
|
||||
|
||||
void DeviceHandlerFailureIsolation::setFaulty(Event reason) {
|
||||
sif::debug<<"DH_FDIR: setFaulty"<<std::endl;
|
||||
throwFdirEvent(FDIR_TURNS_OFF_DEVICE, EVENT::getEventId(reason));
|
||||
setOwnerHealth(HasHealthIF::FAULTY);
|
||||
setFdirState(AWAIT_SHUTDOWN);
|
||||
|
@ -41,7 +41,7 @@ ReturnValue_t ArduinoDH::buildTransitionDeviceCommand(DeviceCommandId_t *id) {
|
||||
|
||||
void ArduinoDH::doTransition(Mode_t modeFrom, Submode_t submodeFrom) {
|
||||
if (mode == _MODE_TO_NORMAL) {
|
||||
std::cout<<"Arduino device -> Transition to Normal mode"<<std::endl;
|
||||
std::cout<<"Arduino device is in Normal mode"<<std::endl;
|
||||
} else {
|
||||
setMode(_MODE_TO_NORMAL);
|
||||
}
|
||||
@ -127,7 +127,7 @@ ReturnValue_t ArduinoDH::interpretDeviceReply(DeviceCommandId_t id,
|
||||
}
|
||||
|
||||
// All data are here printed to monitor from the three vectors of data measurements.
|
||||
printf(
|
||||
/*printf(
|
||||
"\n***********************************************************************************************\n");
|
||||
printf("TEMPERATURE parameters are: ");
|
||||
|
||||
@ -230,7 +230,7 @@ ReturnValue_t ArduinoDH::interpretDeviceReply(DeviceCommandId_t id,
|
||||
printf("\nTimestamp: %u", vecAcc[3 * k + 2].Timestamp[i]);
|
||||
}
|
||||
printf("\nEnd: %7s", vecAcc[3 * k + 2].end_string);
|
||||
}
|
||||
}*/
|
||||
|
||||
std::cout << "\n\nEnd reading data.\n" << std::endl;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user