Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1087, do not register RTOS timer for external sync #1091

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions src/os/vxworks/src/os-impl-timebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,22 +225,31 @@ void OS_VxWorks_RegisterTimer(osal_id_t obj_id)
{
local = OS_OBJECT_TABLE_GET(OS_impl_timebase_table, token);

memset(&evp, 0, sizeof(evp));
evp.sigev_notify = SIGEV_SIGNAL;
evp.sigev_signo = local->assigned_signal;
if (local->assigned_signal == 0)
{
/* nothing to register in RTOS */
status = 0;
}
else
{
memset(&evp, 0, sizeof(evp));
evp.sigev_notify = SIGEV_SIGNAL;
evp.sigev_signo = local->assigned_signal;

/*
** Create the timer
**
** The result is not returned from this function, because
** this is a different task context from the original creator.
**
** The registration status is returned through the OS_impl_timebase_table entry,
** which is checked by the creator before returning.
**
** If set to ERROR, then this task will be subsequently deleted.
*/
status = timer_create(OS_PREFERRED_CLOCK, &evp, &local->host_timerid);
}

/*
** Create the timer
**
** The result is not returned from this function, because
** this is a different task context from the original creator.
**
** The registration status is returned through the OS_impl_timebase_table entry,
** which is checked by the creator before returning.
**
** If set to ERROR, then this task will be subsequently deleted.
*/
status = timer_create(OS_PREFERRED_CLOCK, &evp, &local->host_timerid);
if (status < 0)
{
OS_DEBUG("timer_create() failed: errno=%d\n", errno);
Expand Down Expand Up @@ -529,8 +538,8 @@ int32 OS_TimeBaseSet_Impl(const OS_object_token_t *token, uint32 start_time, uin
/* There is only something to do here if we are generating a simulated tick */
if (local->assigned_signal <= 0)
{
/* An externally synced timebase does not need to be set */
return_code = OS_ERR_NOT_IMPLEMENTED;
/* An externally synced timebase does not need to be set (noop) */
return_code = OS_SUCCESS;
}
else
{
Expand Down
29 changes: 20 additions & 9 deletions src/unit-test-coverage/vxworks/src/coveragetest-timebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,29 @@ void Test_OS_TimeBaseCreate_Impl(void)
/*
* Check outputs of OS_VxWorks_RegisterTimer() function.
*/
UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_1);
UT_TimeBaseTest_CallRegisterTimer(OS_OBJECT_ID_UNDEFINED);
UtAssert_True(UT_TimeBaseTest_CheckTimeBaseRegisteredState(UT_INDEX_0), "timer successfully registered");

UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_1);
UT_TimeBaseTest_Setup(UT_INDEX_0, 10, false);
UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_0);
UT_TimeBaseTest_CallRegisterTimer(token.obj_id);
UtAssert_True(UT_TimeBaseTest_CheckTimeBaseRegisteredState(UT_INDEX_0),
"timer successfully registered, with signal");

UT_TimeBaseTest_Setup(UT_INDEX_0, 10, false);
UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_0);
UT_SetDefaultReturnValue(UT_KEY(OCS_timer_create), -1);
UT_TimeBaseTest_CallRegisterTimer(OS_OBJECT_ID_UNDEFINED);
UT_TimeBaseTest_CallRegisterTimer(token.obj_id);
UtAssert_True(UT_TimeBaseTest_CheckTimeBaseErrorState(UT_INDEX_0), "timer registration failure state");

UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_1);
UT_TimeBaseTest_Setup(UT_INDEX_0, 10, false);
UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_0);
UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetById), OS_ERROR);
UT_TimeBaseTest_CallRegisterTimer(OS_OBJECT_ID_UNDEFINED);
UT_TimeBaseTest_CallRegisterTimer(token.obj_id);
UtAssert_True(!UT_TimeBaseTest_CheckTimeBaseRegisteredState(UT_INDEX_0), "timer registration bad ID");
UT_ResetState(UT_KEY(OS_ObjectIdGetById));

UT_TimeBaseTest_Setup(UT_INDEX_0, 0, false);
UT_TimeBaseTest_ClearTimeBaseRegState(UT_INDEX_0);
UT_TimeBaseTest_CallRegisterTimer(token.obj_id);
UtAssert_True(UT_TimeBaseTest_CheckTimeBaseRegisteredState(UT_INDEX_0), "timer successfully registered, no signal");
}

void Test_OS_VxWorks_SigWait(void)
Expand Down Expand Up @@ -217,7 +227,8 @@ void Test_OS_TimeBaseSet_Impl(void)
*/
OS_object_token_t token = UT_TOKEN_0;

OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(&token, 1, 1), OS_ERR_NOT_IMPLEMENTED);
UT_TimeBaseTest_Setup(UT_INDEX_0, 0, false);
OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(&token, 1, 1), OS_SUCCESS);

UT_TimeBaseTest_Setup(UT_INDEX_0, OCS_SIGRTMIN, false);
OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(&token, 1, 1), OS_SUCCESS);
Expand Down