Node handling corrected
This commit is contained in:
parent
9ac0b4ff69
commit
18d169eaa5
|
|
@ -56,6 +56,13 @@ static TestBenchData_en testBenchData_en;
|
|||
static uint8 currentNode_gu8 = 0u;
|
||||
static SdlTestBenchState_en testBenchState_en = TEST_BENCH_IDLE;
|
||||
static uint32 readPosition_gu32;
|
||||
static uint8 batchCompleted_u8 = 1u; /* Indicates if we need to populate a new batch */
|
||||
static uint64 readExecutedTime_u64 = 0uLL;
|
||||
static uint64 writeTime_u64 = 0uLL;
|
||||
static uint8 position_u8;
|
||||
|
||||
static uint16 writeCounter;
|
||||
static uint16 readCounter;
|
||||
/******************************************************************************
|
||||
* Public Function Definitions
|
||||
******************************************************************************/
|
||||
|
|
@ -63,8 +70,8 @@ static uint32 readPosition_gu32;
|
|||
void EnduranceTestBenchRun(void)
|
||||
{
|
||||
static uint64 startTime_u64 = 0uLL;
|
||||
static uint64 timeDelay_u64 = 0uLL;
|
||||
static uint8 alternate_u8 = 0u;
|
||||
static uint8 batchCompleted_u8 = 1u; /* Indicates if we need to populate a new batch */
|
||||
static uint8 retries_u8 = 0u;
|
||||
uint64 currentTime_u64;
|
||||
|
||||
|
|
@ -155,20 +162,21 @@ void EnduranceTestBenchRun(void)
|
|||
|
||||
|
||||
case TEST_BENCH_WRITE_REQUEST:
|
||||
{
|
||||
if (batchCompleted_u8 == 0)
|
||||
{
|
||||
if (currentNode_gu8 < ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
||||
{
|
||||
testBenchData_en.targetPositions_gau8[currentNode_gu8] = (uint8)(rand() % 256);
|
||||
testBenchData_en.targetPositions_gau8[currentNode_gu8] = (uint8)(rand() % 255);
|
||||
|
||||
RET_T retVal_en = coSdoWrite((1), ENDURANCE_TEST_BENCH_POSITION_SETPOINT_INDEX, ENDURANCE_TEST_BENCH_POSITION_SETPOINT_SUB_INDEX,
|
||||
&testBenchData_en.targetPositions_gau8[currentNode_gu8], sizeof(uint8),
|
||||
CO_FALSE, ENDURANCE_TEST_BENCH_TIMEOUT);
|
||||
RET_T retVal_en = coSdoWrite((19), ENDURANCE_TEST_BENCH_POSITION_SETPOINT_INDEX, ENDURANCE_TEST_BENCH_POSITION_SETPOINT_SUB_INDEX,
|
||||
&testBenchData_en.targetPositions_gau8[currentNode_gu8], sizeof(uint8), CO_FALSE, ENDURANCE_TEST_BENCH_TIMEOUT);
|
||||
|
||||
if (retVal_en == RET_OK)
|
||||
{
|
||||
retries_u8 = 0u;
|
||||
currentNode_gu8++;
|
||||
HalSystemGetRunTimeMs(&startTime_u64);
|
||||
HalSystemGetRunTimeMs(&writeTime_u64);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -180,16 +188,21 @@ void EnduranceTestBenchRun(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TEST_BENCH_READ_FEEDBACK:
|
||||
{
|
||||
RET_T retVal_en = coSdoRead((1),ENDURANCE_TEST_BENCH_POSITION_FEEDBACK_INDEX, ENDURANCE_TEST_BENCH_POSITION_FEEDBACK_SUB_INDEX,
|
||||
if (currentNode_gu8 < ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
||||
{
|
||||
RET_T retVal_en = coSdoRead((19),ENDURANCE_TEST_BENCH_POSITION_FEEDBACK_INDEX, ENDURANCE_TEST_BENCH_POSITION_FEEDBACK_SUB_INDEX,
|
||||
(uint8*)&readPosition_gu32, sizeof(uint32), CO_FALSE, ENDURANCE_TEST_BENCH_TIMEOUT);
|
||||
|
||||
if (retVal_en == RET_OK)
|
||||
{
|
||||
/* Wait for indication */
|
||||
retries_u8 = 0u;
|
||||
currentNode_gu8++;
|
||||
}
|
||||
|
||||
else if (retVal_en == RET_SERVICE_BUSY && retries_u8 < ENDURANCE_TEST_BENCH_MAX_RETRY_CNT)
|
||||
|
|
@ -199,22 +212,24 @@ void EnduranceTestBenchRun(void)
|
|||
else
|
||||
{
|
||||
currentNode_gu8++;
|
||||
retries_u8 = 0;
|
||||
retries_u8 = 0u;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TEST_BENCH_VERIFY_RESULTS:
|
||||
{
|
||||
timeDelay_u64 = readExecutedTime_u64 - writeTime_u64;
|
||||
for (uint8 index_u8 = 0u; index_u8 < ENDURANCE_TEST_BENCH_LSS_NODE_COUNT; index_u8++)
|
||||
{
|
||||
if (testBenchData_en.targetPositions_gau8[index_u8] != testBenchData_en.readPosition_gau8[index_u8])
|
||||
if (testBenchData_en.targetPositions_gau8[index_u8] - testBenchData_en.readPosition_gau8[index_u8] <= 2u)
|
||||
{
|
||||
testBenchData_en.status[index_u8] = 1u;
|
||||
testBenchData_en.status[index_u8] = 0u;
|
||||
}
|
||||
else
|
||||
{
|
||||
testBenchData_en.status[index_u8] = 0u;
|
||||
testBenchData_en.status[index_u8] = 1u;
|
||||
}
|
||||
}
|
||||
testBenchState_en = TEST_BENCH_DELAY_BEFORE_NEXT;
|
||||
|
|
@ -237,14 +252,16 @@ void EnduranceTestBenchRun(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Callback Function
|
||||
******************************************************************************/
|
||||
void EnduranceTestBenchWriteInd(uint8 sdoNr_u8, uint16 index_u16, uint8 subIndex_u8, uint32 errorVal_u32)
|
||||
{
|
||||
writeCounter++;
|
||||
HalSystemGetRunTimeMs(&writeTime_u64);
|
||||
if (currentNode_gu8 < ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
||||
{
|
||||
HAL_Delay(100);
|
||||
testBenchState_en = TEST_BENCH_WRITE_REQUEST;
|
||||
}
|
||||
else
|
||||
|
|
@ -257,17 +274,17 @@ void EnduranceTestBenchWriteInd(uint8 sdoNr_u8, uint16 index_u16, uint8 subIndex
|
|||
|
||||
void EnduranceTestBenchReadInd(uint8 sdoNr_u8, uint16 index_u16, uint8 subIndex_u8, uint32 size, uint32 errorVal_u32)
|
||||
{
|
||||
if (sdoNr_u8 <= ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
||||
{
|
||||
testBenchData_en.readPosition_gau8[currentNode_gu8] = readPosition_gu32;
|
||||
readCounter++;
|
||||
HalSystemGetRunTimeMs(&readExecutedTime_u64);
|
||||
testBenchData_en.readPosition_gau8[currentNode_gu8 - 1u] = (uint8)readPosition_gu32;
|
||||
|
||||
if (currentNode_gu8 + 1 == ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
||||
{
|
||||
testBenchState_en = TEST_BENCH_VERIFY_RESULTS;
|
||||
}
|
||||
else
|
||||
if (currentNode_gu8 < ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
||||
{
|
||||
testBenchState_en = TEST_BENCH_READ_FEEDBACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentNode_gu8 = 0u;
|
||||
testBenchState_en = TEST_BENCH_VERIFY_RESULTS;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user