Gong Ke | 497c4c2 | 2020-03-20 10:15:42 +0800 | [diff] [blame] | 1 | /** |
| 2 | * \file |
| 3 | * \brief Utility functions |
| 4 | */ |
| 5 | |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 6 | #ifndef _DVR_UTILS_H_ |
| 7 | #define _DVR_UTILS_H_ |
| 8 | |
| 9 | #ifdef __cplusplus |
| 10 | extern "C" { |
| 11 | #endif |
| 12 | |
| 13 | /**\brief Write a string cmd to a file |
Gong Ke | 497c4c2 | 2020-03-20 10:15:42 +0800 | [diff] [blame] | 14 | * \param[in] name File name |
| 15 | * \param[in] cmd String command |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 16 | * \return DVR_SUCCESS On success |
| 17 | * \return Error code On failure |
| 18 | */ |
hualing chen | a540a7e | 2020-03-27 16:44:05 +0800 | [diff] [blame] | 19 | int dvr_file_echo(const char *name, const char *cmd); |
| 20 | |
hualing chen | a540a7e | 2020-03-27 16:44:05 +0800 | [diff] [blame] | 21 | /**\brief read sysfs file |
| 22 | * \param[in] name, File name |
| 23 | * \param[out] buf, store sysfs node value |
| 24 | * \return DVR_SUCCESS On success |
| 25 | * \return Error code On failure |
| 26 | */ |
hualing chen | a540a7e | 2020-03-27 16:44:05 +0800 | [diff] [blame] | 27 | int dvr_file_read(const char *name, char *buf, int len); |
| 28 | |
wentao ma | 7d64278 | 2022-10-23 18:26:16 -0700 | [diff] [blame^] | 29 | /**\brief read property value |
| 30 | * \param[in] name, property name |
| 31 | * \param[out] buf, property value |
hualing chen | a540a7e | 2020-03-27 16:44:05 +0800 | [diff] [blame] | 32 | * \return DVR_SUCCESS On success |
wentao ma | 7d64278 | 2022-10-23 18:26:16 -0700 | [diff] [blame^] | 33 | * \return DVR_FAILURE On failure |
hualing chen | a540a7e | 2020-03-27 16:44:05 +0800 | [diff] [blame] | 34 | */ |
hualing chen | a540a7e | 2020-03-27 16:44:05 +0800 | [diff] [blame] | 35 | int dvr_prop_read(const char *name, char *buf, int len); |
Gong Ke | 497c4c2 | 2020-03-20 10:15:42 +0800 | [diff] [blame] | 36 | |
wentao ma | 7d64278 | 2022-10-23 18:26:16 -0700 | [diff] [blame^] | 37 | /**\brief write property value |
| 38 | * \param[in] name, property name |
| 39 | * \param[in] value, property value |
| 40 | * \return DVR_SUCCESS On success |
| 41 | * \return DVR_FAILURE On failure |
| 42 | */ |
| 43 | int dvr_prop_write(const char *name, char *value); |
| 44 | |
| 45 | /**\brief read int type property value |
| 46 | * \param[in] name, property name |
| 47 | * \param[in] def, default property value in case any failure |
| 48 | * \return int type property value. If any failure default value will be returned instead |
| 49 | */ |
| 50 | int dvr_prop_read_int(const char *name, int def); |
| 51 | |
Wentao MA | 907b643 | 2022-08-01 06:23:08 +0000 | [diff] [blame] | 52 | /**\brief calculates the difference between ts1 and ts2 |
| 53 | * \param[in] ts1, higher bound of the timespec* whose length is calculated |
| 54 | * \param[in] ts2, lower bound of the timespec* whose length is calculated |
| 55 | * \param[out] ts3, The result timespec* of (ts1-ts2) |
| 56 | * \return void |
| 57 | */ |
| 58 | void clock_timespec_subtract(struct timespec *ts1, struct timespec *ts2, struct timespec *ts3); |
| 59 | |
Pengfei Liu | b473423 | 2020-01-17 18:25:10 +0800 | [diff] [blame] | 60 | #ifdef __cplusplus |
| 61 | } |
| 62 | #endif |
| 63 | |
| 64 | #endif /*END _DVR_UTILS_H_*/ |