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

View File

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

View File

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