1
0
forked from fsfw/fsfw

new adaptions for cookie + comIF changes

hook for performOp() added
This commit is contained in:
2020-03-23 18:03:00 +01:00
parent e03aff3731
commit 029b2133e6
2 changed files with 151 additions and 114 deletions

View File

@ -16,37 +16,34 @@ object_id_t DeviceHandlerBase::powerSwitcherId = 0;
object_id_t DeviceHandlerBase::rawDataReceiverId = 0;
object_id_t DeviceHandlerBase::defaultFDIRParentId = 0;
DeviceHandlerBase::DeviceHandlerBase(uint32_t logicalAddress_,
object_id_t setObjectId, uint32_t maxDeviceReplyLen,
uint8_t setDeviceSwitch, object_id_t deviceCommunication,
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId,
FailureIsolationBase* fdirInstance, uint32_t cmdQueueSize) :
SystemObject(setObjectId), rawPacket(0), rawPacketLen(0), mode(MODE_OFF),
submode(SUBMODE_NONE), pstStep(0), maxDeviceReplyLen(maxDeviceReplyLen),
wiretappingMode(OFF), defaultRawReceiver(0), storedRawData(StorageManagerIF::INVALID_ADDRESS),
requestedRawTraffic(0), powerSwitcher(NULL), IPCStore(NULL),
deviceCommunicationId(deviceCommunication), communicationInterface(NULL),
cookie(NULL), commandQueue(NULL), deviceThermalStatePoolId(thermalStatePoolId),
deviceThermalRequestPoolId(thermalRequestPoolId), healthHelper(this, setObjectId),
modeHelper(this), parameterHelper(this), childTransitionFailure(RETURN_OK),
ignoreMissedRepliesCount(0), fdirInstance(fdirInstance), hkSwitcher(this),
defaultFDIRUsed(fdirInstance == NULL), switchOffWasReported(false),
executingTask(NULL), actionHelper(this, NULL), cookieInfo(), logicalAddress(logicalAddress_),
timeoutStart(0), childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN),
transitionSourceSubMode(SUBMODE_NONE), deviceSwitch(setDeviceSwitch)
DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, address_t logicalAddress_,
object_id_t deviceCommunication, Cookie * cookie_, size_t maxReplyLen,
uint8_t setDeviceSwitch, uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId,
FailureIsolationBase* fdirInstance, size_t cmdQueueSize) :
SystemObject(setObjectId), mode(MODE_OFF), submode(SUBMODE_NONE),
wiretappingMode(OFF), storedRawData(StorageManagerIF::INVALID_ADDRESS),
deviceCommunicationId(deviceCommunication), cookie(cookie_),
deviceThermalStatePoolId(thermalStatePoolId), deviceThermalRequestPoolId(thermalRequestPoolId),
healthHelper(this, setObjectId), modeHelper(this), parameterHelper(this),
fdirInstance(fdirInstance), hkSwitcher(this),
defaultFDIRUsed(fdirInstance == nullptr), switchOffWasReported(false),
executingTask(nullptr), actionHelper(this, nullptr), cookieInfo(),
logicalAddress(logicalAddress_), childTransitionDelay(5000),
transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(SUBMODE_NONE),
deviceSwitch(setDeviceSwitch)
{
this->cookie->setMaxReplyLen(maxReplyLen);
commandQueue = QueueFactory::instance()->
createMessageQueue(cmdQueueSize, CommandMessage::MAX_MESSAGE_SIZE);
cookieInfo.state = COOKIE_UNUSED;
insertInCommandMap(RAW_COMMAND_ID);
if (this->fdirInstance == NULL) {
if (this->fdirInstance == nullptr) {
this->fdirInstance =
new DeviceHandlerFailureIsolation(setObjectId, defaultFDIRParentId);
}
}
DeviceHandlerBase::~DeviceHandlerBase() {
communicationInterface->close(cookie);
if (defaultFDIRUsed) {
delete fdirInstance;
}
@ -63,10 +60,12 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
decrementDeviceReplyMap();
fdirInstance->checkForFailures();
hkSwitcher.performOperation();
performOperationHook();
}
if (mode == MODE_OFF) {
return RETURN_OK;
}
switch (getRmapAction()) {
case SEND_WRITE:
if ((cookieInfo.state == COOKIE_UNUSED)) {
@ -87,6 +86,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
default:
break;
}
return RETURN_OK;
}
@ -102,11 +102,11 @@ ReturnValue_t DeviceHandlerBase::initialize() {
return RETURN_FAILED;
}
result = communicationInterface->open(&cookie, logicalAddress,
maxDeviceReplyLen);
if (result != RETURN_OK) {
return result;
}
// result = communicationInterface->open(&cookie, logicalAddress,
// maxDeviceReplyLen, comParameter1, comParameter2);
// if (result != RETURN_OK) {
// return result;
// }
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
if (IPCStore == NULL) {
@ -166,7 +166,6 @@ ReturnValue_t DeviceHandlerBase::initialize() {
mySet.commit(PoolVariableIF::VALID);
return RETURN_OK;
}
void DeviceHandlerBase::decrementDeviceReplyMap() {
@ -549,7 +548,7 @@ void DeviceHandlerBase::doGetWrite() {
void DeviceHandlerBase::doSendRead() {
ReturnValue_t result;
result = communicationInterface->requestReceiveMessage(cookie);
result = communicationInterface->requestReceiveMessage(cookie, requestLen);
if (result == RETURN_OK) {
cookieInfo.state = COOKIE_READ_SENT;
} else {
@ -563,10 +562,10 @@ void DeviceHandlerBase::doSendRead() {
}
void DeviceHandlerBase::doGetRead() {
uint32_t receivedDataLen;
size_t receivedDataLen;
uint8_t *receivedData;
DeviceCommandId_t foundId = 0xFFFFFFFF;
uint32_t foundLen = 0;
size_t foundLen = 0;
ReturnValue_t result;
if (cookieInfo.state != COOKIE_READ_SENT) {
@ -637,8 +636,8 @@ void DeviceHandlerBase::doGetRead() {
}
ReturnValue_t DeviceHandlerBase::getStorageData(store_address_t storageAddress,
uint8_t * *data, uint32_t * len) {
uint32_t lenTmp;
uint8_t ** data, size_t * len) {
size_t lenTmp;
if (IPCStore == NULL) {
*data = NULL;
@ -689,7 +688,7 @@ void DeviceHandlerBase::replyRawData(const uint8_t *data, size_t len,
//Default child implementations
DeviceHandlerBase::RmapAction_t DeviceHandlerBase::getRmapAction() {
DeviceHandlerBase::CommunicationAction_t DeviceHandlerBase::getRmapAction() {
switch (pstStep) {
case 0:
return SEND_WRITE;
@ -749,20 +748,20 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData,
}
}
ReturnValue_t DeviceHandlerBase::switchCookieChannel(object_id_t newChannelId) {
DeviceCommunicationIF *newCommunication = objectManager->get<
DeviceCommunicationIF>(newChannelId);
if (newCommunication != NULL) {
ReturnValue_t result = newCommunication->reOpen(cookie, logicalAddress,
maxDeviceReplyLen);
if (result != RETURN_OK) {
return result;
}
return RETURN_OK;
}
return RETURN_FAILED;
}
//ReturnValue_t DeviceHandlerBase::switchCookieChannel(object_id_t newChannelId) {
// DeviceCommunicationIF *newCommunication = objectManager->get<
// DeviceCommunicationIF>(newChannelId);
//
// if (newCommunication != NULL) {
// ReturnValue_t result = newCommunication->reOpen(cookie, logicalAddress,
// maxDeviceReplyLen, comParameter1, comParameter2);
// if (result != RETURN_OK) {
// return result;
// }
// return RETURN_OK;
// }
// return RETURN_FAILED;
//}
void DeviceHandlerBase::buildRawDeviceCommand(CommandMessage* commandMessage) {
storedRawData = DeviceHandlerMessage::getStoreAddress(commandMessage);
@ -1046,12 +1045,13 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(
}
replyReturnvalueToCommand(RETURN_OK);
return RETURN_OK;
case DeviceHandlerMessage::CMD_SWITCH_IOBOARD:
case DeviceHandlerMessage::CMD_SWITCH_ADDRESS:
if (mode != MODE_OFF) {
replyReturnvalueToCommand(WRONG_MODE_FOR_COMMAND);
} else {
result = switchCookieChannel(
DeviceHandlerMessage::getIoBoardObjectId(message));
// rework in progress
//result = switchCookieChannel(
// DeviceHandlerMessage::getIoBoardObjectId(message));
if (result == RETURN_OK) {
replyReturnvalueToCommand(RETURN_OK);
} else {
@ -1278,3 +1278,6 @@ void DeviceHandlerBase::debugInterface(uint8_t positionTracker, object_id_t obje
uint32_t DeviceHandlerBase::getLogicalAddress() {
return logicalAddress;
}
void DeviceHandlerBase::performOperationHook() {
}