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 uint8 currentNode_gu8 = 0u;
|
||||||
static SdlTestBenchState_en testBenchState_en = TEST_BENCH_IDLE;
|
static SdlTestBenchState_en testBenchState_en = TEST_BENCH_IDLE;
|
||||||
static uint32 readPosition_gu32;
|
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
|
* Public Function Definitions
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
@ -63,8 +70,8 @@ static uint32 readPosition_gu32;
|
||||||
void EnduranceTestBenchRun(void)
|
void EnduranceTestBenchRun(void)
|
||||||
{
|
{
|
||||||
static uint64 startTime_u64 = 0uLL;
|
static uint64 startTime_u64 = 0uLL;
|
||||||
|
static uint64 timeDelay_u64 = 0uLL;
|
||||||
static uint8 alternate_u8 = 0u;
|
static uint8 alternate_u8 = 0u;
|
||||||
static uint8 batchCompleted_u8 = 1u; /* Indicates if we need to populate a new batch */
|
|
||||||
static uint8 retries_u8 = 0u;
|
static uint8 retries_u8 = 0u;
|
||||||
uint64 currentTime_u64;
|
uint64 currentTime_u64;
|
||||||
|
|
||||||
|
|
@ -155,66 +162,74 @@ void EnduranceTestBenchRun(void)
|
||||||
|
|
||||||
|
|
||||||
case TEST_BENCH_WRITE_REQUEST:
|
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() % 255);
|
||||||
|
|
||||||
|
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(&writeTime_u64);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retries_u8++;
|
||||||
|
if (retries_u8 >= ENDURANCE_TEST_BENCH_MAX_RETRY_CNT)
|
||||||
|
{
|
||||||
|
currentNode_gu8++; /* Skip this node */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TEST_BENCH_READ_FEEDBACK:
|
||||||
{
|
{
|
||||||
if (currentNode_gu8 < ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
if (currentNode_gu8 < ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
||||||
{
|
{
|
||||||
testBenchData_en.targetPositions_gau8[currentNode_gu8] = (uint8)(rand() % 256);
|
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);
|
||||||
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);
|
|
||||||
|
|
||||||
if (retVal_en == RET_OK)
|
if (retVal_en == RET_OK)
|
||||||
{
|
{
|
||||||
retries_u8 = 0u;
|
retries_u8 = 0u;
|
||||||
currentNode_gu8++;
|
currentNode_gu8++;
|
||||||
HalSystemGetRunTimeMs(&startTime_u64);
|
}
|
||||||
|
|
||||||
|
else if (retVal_en == RET_SERVICE_BUSY && retries_u8 < ENDURANCE_TEST_BENCH_MAX_RETRY_CNT)
|
||||||
|
{
|
||||||
|
retries_u8++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
retries_u8++;
|
currentNode_gu8++;
|
||||||
if (retries_u8 >= ENDURANCE_TEST_BENCH_MAX_RETRY_CNT)
|
retries_u8 = 0u;
|
||||||
{
|
|
||||||
currentNode_gu8++; /* Skip this node */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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,
|
|
||||||
(uint8*)&readPosition_gu32, sizeof(uint32), CO_FALSE, ENDURANCE_TEST_BENCH_TIMEOUT);
|
|
||||||
|
|
||||||
if (retVal_en == RET_OK)
|
|
||||||
{
|
|
||||||
/* Wait for indication */
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (retVal_en == RET_SERVICE_BUSY && retries_u8 < ENDURANCE_TEST_BENCH_MAX_RETRY_CNT)
|
|
||||||
{
|
|
||||||
retries_u8++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentNode_gu8++;
|
|
||||||
retries_u8 = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TEST_BENCH_VERIFY_RESULTS:
|
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++)
|
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
|
else
|
||||||
{
|
{
|
||||||
testBenchData_en.status[index_u8] = 0u;
|
testBenchData_en.status[index_u8] = 1u;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
testBenchState_en = TEST_BENCH_DELAY_BEFORE_NEXT;
|
testBenchState_en = TEST_BENCH_DELAY_BEFORE_NEXT;
|
||||||
|
|
@ -237,14 +252,16 @@ void EnduranceTestBenchRun(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Callback Function
|
* Callback Function
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void EnduranceTestBenchWriteInd(uint8 sdoNr_u8, uint16 index_u16, uint8 subIndex_u8, uint32 errorVal_u32)
|
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)
|
if (currentNode_gu8 < ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
||||||
{
|
{
|
||||||
|
HAL_Delay(100);
|
||||||
testBenchState_en = TEST_BENCH_WRITE_REQUEST;
|
testBenchState_en = TEST_BENCH_WRITE_REQUEST;
|
||||||
}
|
}
|
||||||
else
|
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)
|
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)
|
readCounter++;
|
||||||
{
|
HalSystemGetRunTimeMs(&readExecutedTime_u64);
|
||||||
testBenchData_en.readPosition_gau8[currentNode_gu8] = readPosition_gu32;
|
testBenchData_en.readPosition_gau8[currentNode_gu8 - 1u] = (uint8)readPosition_gu32;
|
||||||
|
|
||||||
if (currentNode_gu8 + 1 == ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
if (currentNode_gu8 < ENDURANCE_TEST_BENCH_LSS_NODE_COUNT)
|
||||||
{
|
{
|
||||||
testBenchState_en = TEST_BENCH_VERIFY_RESULTS;
|
testBenchState_en = TEST_BENCH_READ_FEEDBACK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
testBenchState_en = TEST_BENCH_READ_FEEDBACK;
|
currentNode_gu8 = 0u;
|
||||||
}
|
testBenchState_en = TEST_BENCH_VERIFY_RESULTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user