1 /******************************************************************************
2  *
3  *  Copyright (C) 2018 ST Microelectronics S.A.
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *
18  ******************************************************************************/
19 #ifndef UTILS_H_
20 #define UTILS_H_
21 
22 #include <sys/time.h>
23 
24 /**
25  * Converts the given char array into its HEX-based string representation.
26  *
27  * @param array The char array to be converted.
28  * @param length The length of the char array.
29  * @param hexString Out param where the result will be stored.
30  *
31  * @return 0 on successful conversion, -1 otherwise.
32  */
33 int Utils_charArrayToHexString(char* array, int length, char* hexString);
34 
35 char* convert(uint8_t* buf);
36 
37 /**
38  * Returns the difference of time (in ms) between t1 and t2.
39  *
40  * @param t1 The initial time.
41  * @param t2 The final time.
42  *
43  * @return The difference t2 - t1 in ms.
44  */
45 int Utils_getElapsedTimeInMs(struct timeval t1, struct timeval t2);
46 
47 /**
48  * Prints current time to standard log.
49  *
50  * @param prefix The prefix to be printed before the time.
51  */
52 void Utils_printCurrentTime(char* prefix);
53 
54 #endif /* UTILS_H_ */
55