Merge pull request 'DHB tweak and class ID for GPIO HAL' (#434) from eive/fsfw:mueller/dhb-tweak into development

Reviewed-on: #434
This commit is contained in:
Steffen Gaisser 2021-06-15 15:23:23 +02:00
commit fbbc640f4d
3 changed files with 16 additions and 15 deletions

View File

@ -226,16 +226,15 @@ ReturnValue_t DeviceHandlerBase::initialize() {
} }
void DeviceHandlerBase::decrementDeviceReplyMap() { void DeviceHandlerBase::decrementDeviceReplyMap() {
for (std::map<DeviceCommandId_t, DeviceReplyInfo>::iterator iter = for (std::pair<const DeviceCommandId_t, DeviceReplyInfo>& replyPair: deviceReplyMap) {
deviceReplyMap.begin(); iter != deviceReplyMap.end(); iter++) { if (replyPair.second.delayCycles != 0) {
if (iter->second.delayCycles != 0) { replyPair.second.delayCycles--;
iter->second.delayCycles--; if (replyPair.second.delayCycles == 0) {
if (iter->second.delayCycles == 0) { if (replyPair.second.periodic) {
if (iter->second.periodic) { replyPair.second.delayCycles = replyPair.second.maxDelayCycles;
iter->second.delayCycles = iter->second.maxDelayCycles;
} }
replyToReply(iter, TIMEOUT); replyToReply(replyPair.first, replyPair.second, TIMEOUT);
missedReply(iter->first); missedReply(replyPair.first);
} }
} }
} }
@ -584,16 +583,16 @@ void DeviceHandlerBase::replyToCommand(ReturnValue_t status,
} }
} }
void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter, void DeviceHandlerBase::replyToReply(const DeviceCommandId_t command, DeviceReplyInfo& replyInfo,
ReturnValue_t status) { ReturnValue_t status) {
// No need to check if iter exists, as this is checked by callers. // No need to check if iter exists, as this is checked by callers.
// If someone else uses the method, add check. // If someone else uses the method, add check.
if (iter->second.command == deviceCommandMap.end()) { if (replyInfo.command == deviceCommandMap.end()) {
//Is most likely periodic reply. Silent return. //Is most likely periodic reply. Silent return.
return; return;
} }
// Check if more replies are expected. If so, do nothing. // Check if more replies are expected. If so, do nothing.
DeviceCommandInfo* info = &(iter->second.command->second); DeviceCommandInfo* info = &replyInfo.command->second;
if (--info->expectedReplies == 0) { if (--info->expectedReplies == 0) {
// Check if it was transition or internal command. // Check if it was transition or internal command.
// Don't send any replies in that case. // Don't send any replies in that case.
@ -602,7 +601,7 @@ void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter,
if(status == HasReturnvaluesIF::RETURN_OK) { if(status == HasReturnvaluesIF::RETURN_OK) {
success = true; success = true;
} }
actionHelper.finish(success, info->sendReplyTo, iter->first, status); actionHelper.finish(success, info->sendReplyTo, command, status);
} }
info->isExecuting = false; info->isExecuting = false;
} }
@ -801,7 +800,7 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData,
replyRawReplyIfnotWiretapped(receivedData, foundLen); replyRawReplyIfnotWiretapped(receivedData, foundLen);
triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result, foundId); triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result, foundId);
} }
replyToReply(iter, result); replyToReply(iter->first, iter->second, result);
} }
else { else {
/* Other completion failure messages are created by timeout. /* Other completion failure messages are created by timeout.

View File

@ -1195,7 +1195,8 @@ private:
* @foundLen the length of the packet * @foundLen the length of the packet
*/ */
void handleReply(const uint8_t *data, DeviceCommandId_t id, uint32_t foundLen); void handleReply(const uint8_t *data, DeviceCommandId_t id, uint32_t foundLen);
void replyToReply(DeviceReplyMap::iterator iter, ReturnValue_t status); void replyToReply(const DeviceCommandId_t command, DeviceReplyInfo& replyInfo,
ReturnValue_t status);
/** /**
* Build and send a command to the device. * Build and send a command to the device.

View File

@ -75,6 +75,7 @@ enum: uint8_t {
HAL_SPI, //HSPI HAL_SPI, //HSPI
HAL_UART, //HURT HAL_UART, //HURT
HAL_I2C, //HI2C HAL_I2C, //HI2C
HAL_GPIO, //HGIO
FW_CLASS_ID_COUNT // [EXPORT] : [END] FW_CLASS_ID_COUNT // [EXPORT] : [END]
}; };