Skip to content

Commit

Permalink
Merge pull request rdkcentral#5393 from apatel859/sprint/24Q2
Browse files Browse the repository at this point in the history
RDKTV-30790 added retry logic for IARM connect failure
  • Loading branch information
apatel859 authored Jun 10, 2024
2 parents 4b1bee3 + b3b14ea commit 2519a10
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions helpers/UtilsIarm.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "UtilsLogging.h"

#include "libIBus.h"
#include <unistd.h>

#define IARM_CHECK(FUNC) { \
if ((res = FUNC) != IARM_RESULT_SUCCESS) { \
Expand All @@ -29,19 +30,27 @@ struct IARM {
LOGINFO("IARM already connected");
result = true;
} else {
res = IARM_Bus_Init(NAME);
LOGINFO("IARM_Bus_Init: %d", res);
if (res == IARM_RESULT_SUCCESS || res == IARM_RESULT_INVALID_STATE /* already inited or connected */) {
res = IARM_Bus_Connect();
LOGINFO("IARM_Bus_Connect: %d", res);
if (res == IARM_RESULT_SUCCESS || res == IARM_RESULT_INVALID_STATE /* already connected or not inited */) {
result = isConnected();
unsigned int retryCount = 0;
do
{
res = IARM_Bus_Init(NAME);
LOGINFO("IARM_Bus_Init: %d", res);
if (res == IARM_RESULT_SUCCESS || res == IARM_RESULT_INVALID_STATE /* already inited or connected */) {
res = IARM_Bus_Connect();
LOGINFO("IARM_Bus_Connect: %d", res);
if (res == IARM_RESULT_SUCCESS || res == IARM_RESULT_INVALID_STATE /* already connected or not inited */) {
result = isConnected();
LOGERR("ARM_Bus_Connect result: %d res: %d retryCount :%d ",result, res, retryCount);
} else {
LOGERR("IARM_Bus_Connect failure:result :%d res: %d retryCount :%d ",result, res, retryCount);
}
} else {
LOGERR("IARM_Bus_Connect failure: %d", res);
LOGERR("IARM_Bus_Init failure: result :%d res: %d retryCount :%d",result, res,retryCount);
}
} else {
LOGERR("IARM_Bus_Init failure: %d", res);
}

if(result == false) usleep(100000);

}while((result == false) && (retryCount++ < 20));
}

return result;
Expand All @@ -52,7 +61,7 @@ struct IARM {
IARM_Result_t res;
int isRegistered = 0;
res = IARM_Bus_IsConnected(NAME, &isRegistered);
LOGINFO("IARM_Bus_IsConnected: %d (%d)", res, isRegistered);
LOGINFO("IARM_Bus_IsConnected: res:%d isRegistered (%d)", res, isRegistered);

return (isRegistered == 1);
}
Expand Down

0 comments on commit 2519a10

Please sign in to comment.