DHB adaptiosn and improvements, Srv8 update

service 8 does not finish immediately for data replies now
This commit is contained in:
Robin Müller 2021-01-27 13:36:18 +01:00
parent 686ae101ee
commit f40cdcf472
3 changed files with 40 additions and 35 deletions

View File

@ -1202,41 +1202,47 @@ ReturnValue_t DeviceHandlerBase::letChildHandleMessage(
return RETURN_FAILED;
}
void DeviceHandlerBase::handleDeviceTM(SerializeIF* data,
DeviceCommandId_t replyId, bool neverInDataPool, bool forceDirectTm) {
void DeviceHandlerBase::handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId,
bool forceDirectTm = false) {
if(dataSet == nullptr) {
return;
}
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) {
triggerEvent(DEVICE_UNKNOWN_REPLY, replyId);
return;
}
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, data);
//replies to a command
/* Regular replies to a command */
if (iter->second.command != deviceCommandMap.end())
{
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
if (queueId != NO_COMMANDER) {
//This may fail, but we'll ignore the fault.
actionHelper.reportData(queueId, replyId, data);
/* This may fail, but we'll ignore the fault. */
actionHelper.reportData(queueId, replyId, dataSet);
}
//This check should make sure we get any TM but don't get anything doubled.
if (wiretappingMode == TM && (requestedRawTraffic != queueId)) {
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
}
else if (forceDirectTm and (defaultRawReceiver != queueId) and
(defaultRawReceiver != MessageQueueIF::NO_QUEUE))
{
// hiding of sender needed so the service will handle it as
// unexpected Data, no matter what state (progress or completed)
// it is in
actionHelper.reportData(defaultRawReceiver, replyId, &wrapper,
true);
actionHelper.reportData(defaultRawReceiver, replyId, dataSet, true);
}
}
//unrequested/aperiodic replies
/* Unrequested or aperiodic replies */
else
{
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
if (wiretappingMode == TM) {
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
}
@ -1246,17 +1252,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data,
// hiding of sender needed so the service will handle it as
// unexpected Data, no matter what state (progress or completed)
// it is in
actionHelper.reportData(defaultRawReceiver, replyId, &wrapper,
true);
}
}
//Try to cast to GlobDataSet and commit data.
if (not neverInDataPool) {
LocalPoolDataSetBase* dataSet =
dynamic_cast<LocalPoolDataSetBase*>(data);
if (dataSet != nullptr) {
dataSet->setValidity(true, true);
dataSet->commit();
actionHelper.reportData(defaultRawReceiver, replyId, &wrapper, true);
}
}
}

View File

@ -288,23 +288,29 @@ protected:
virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) = 0;
/**
* @brief Build a device command packet from data supplied by a
* direct command.
*
* @brief Build a device command packet from data supplied by a direct
* command (PUS Service 8)
* @details
* #rawPacket and #rawPacketLen should be set by this method to the packet
* to be sent. The existence of the command in the command map and the
* command size check against 0 are done by the base class.
* This will be called if an functional command via PUS Service 8 is received and is
* the primary interface for functional command instead of #executeAction for users. The
* supplied ActionId_t action ID will be converted to a DeviceCommandId_t command ID after
* an internal check whether the action ID is a key in the device command map.
*
* @param deviceCommand the command to build, already checked against
* deviceCommandMap
* @param commandData pointer to the data from the direct command
* @param commandDataLen length of commandData
* #rawPacket and #rawPacketLen should be set by this method to the packet to be sent.
* The existence of the command in the command map and the command size check against 0 are
* done by the base class.
*
* @param deviceCommand The command to build, already checked against deviceCommandMap
* @param commandData Pointer to the data from the direct command
* @param commandDataLen Length of commandData
* @return
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen
* have been set.
* - Anything else triggers an event with the
* returnvalue as a parameter
* - @c HasActionsIF::EXECUTION_COMPLETE to generate a finish reply immediately. This can
* be used if no reply is expected. Otherwise, the developer can call #actionHelper.finish
* to finish the command handling.
* - Anything else triggers an event with the return code as a parameter as well as a
* step reply failed with the return code
*/
virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData, size_t commandDataLen) = 0;
@ -995,8 +1001,10 @@ protected:
bool isAwaitingReply();
void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t commandId,
bool neverInDataPool = false, bool forceDirectTm = false);
void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId,
bool forceDirectTm = false);
void handleDeviceTM(uint8_t* data, size_t dataSize, DeviceCommandId_t replyId,
bool forceDirectTm);
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode);

View File

@ -104,6 +104,7 @@ ReturnValue_t Service8FunctionManagement::handleReply(
break;
}
case ActionMessage::DATA_REPLY: {
*isStep = true;
result = handleDataReply(reply, objectId, actionId);
break;
}