2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 // libraries for replacing PosixBasedOS001 to Linux
18 // PosixBasedOS001TimeApi.c
20 #include <other_service/PosixBasedOS001TimeApi.h>
25 #include <unistd.h> // for using usleep()
26 #include <time.h> // for using clock()
29 // NOTE: Control a device
31 // The number of milliseconds for which to suspend the calling thread from execution.
33 // _CWORD72_ doesnot use return code of delay, and sets 1,100,and 1000.
34 unsigned int delay( unsigned int duration ){
37 useconds_t duration_usec = duration * 1000;
41 if( duration_usec > 1000000 ){
42 printf("delay():over flow!\n");
46 ret = usleep(duration_usec);
48 // error of usleep() = 0(E_OK), -1(ERROR)
49 // delay() cannot return error code. [data type unmatch]
50 if(ret < 0){ // LCOV_EXCL_BR_LINE 5: fail safe for libc function usleep
51 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
52 printf("delay():error!\n"); // LCOV_EXCL_LINE 5: fail safe for libc function usleep