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 #889, report timer_gettime error #907

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
11 changes: 9 additions & 2 deletions src/os/vxworks/src/os-impl-timebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,6 @@ int32 OS_TimeBaseSet_Impl(const OS_object_token_t *token, uint32 start_time, uin

if (status == OK)
{
return_code = OS_SUCCESS;

/*
* VxWorks will round the interval up to the next higher
* system tick interval. Sometimes this can make a substantial
Expand All @@ -565,6 +563,8 @@ int32 OS_TimeBaseSet_Impl(const OS_object_token_t *token, uint32 start_time, uin
status = timer_gettime(local->host_timerid, &timeout);
if (status == OK)
{
return_code = OS_SUCCESS;

local->configured_start_time = (timeout.it_value.tv_sec * 1000000) + (timeout.it_value.tv_nsec / 1000);
local->configured_interval_time =
(timeout.it_interval.tv_sec * 1000000) + (timeout.it_interval.tv_nsec / 1000);
Expand All @@ -582,6 +582,13 @@ int32 OS_TimeBaseSet_Impl(const OS_object_token_t *token, uint32 start_time, uin
(unsigned long)local->configured_interval_time);
}
}
else
{
return_code = OS_ERROR;

OS_DEBUG("WARNING: timer %lu timer_gettime() failed - timer not configured properly?\n",
OS_ObjectIdToInteger(OS_ObjectIdFromToken(token)));
}
}
else
{
Expand Down
7 changes: 6 additions & 1 deletion src/unit-test-coverage/vxworks/src/coveragetest-timebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ void Test_OS_VxWorks_SigWait(void)
UT_SetDataBuffer(UT_KEY(OCS_timer_settime), &config_value, sizeof(config_value), false);
UT_SetDataBuffer(UT_KEY(OCS_timer_gettime), &config_value, sizeof(config_value), false);
UT_TimeBaseTest_Setup(UT_INDEX_0, signo, true);
OS_TimeBaseSet_Impl(&token, 1111111, 2222222);
OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(&token, 1111111, 2222222), OS_SUCCESS);

UT_SetDataBuffer(UT_KEY(OCS_timer_settime), &config_value, sizeof(config_value), false);
UT_SetDeferredRetcode(UT_KEY(OCS_timer_gettime), 1, OCS_ERROR);
UT_TimeBaseTest_Setup(UT_INDEX_0, signo, true);
OSAPI_TEST_FUNCTION_RC(OS_TimeBaseSet_Impl(&token, 1111111, 2222222), OS_ERROR);

UT_SetDataBuffer(UT_KEY(OCS_sigwait), &signo, sizeof(signo), false);
OSAPI_TEST_FUNCTION_RC(UT_TimeBaseTest_CallSigWaitFunc(OS_OBJECT_ID_UNDEFINED), 1111111);
Expand Down