b.liu | ae2dce5 | 2024-08-15 11:09:58 +0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <sys/types.h> |
| 3 | #include <sys/stat.h> |
| 4 | #include <fcntl.h> |
b.liu | 9e8584b | 2024-11-06 19:21:28 +0800 | [diff] [blame] | 5 | #include <stdlib.h> |
| 6 | #include <unistd.h> |
b.liu | ae2dce5 | 2024-08-15 11:09:58 +0800 | [diff] [blame] | 7 | |
| 8 | #include "mbtk_utils.h" |
| 9 | #include "mbtk_log.h" |
| 10 | |
| 11 | #define KMSG "/dev/kmsg" |
| 12 | |
| 13 | static int fd = -1; |
| 14 | |
| 15 | void timer_alrm_cb(int signo) |
| 16 | { |
| 17 | char *str = "----------------------Timeout---------------------------\n"; |
| 18 | if(fd > 0) { |
b.liu | 9e8584b | 2024-11-06 19:21:28 +0800 | [diff] [blame] | 19 | mbtk_write(fd, str, strlen(str)); |
b.liu | ae2dce5 | 2024-08-15 11:09:58 +0800 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | printf("%s", str); |
| 23 | LOGI("%s", str); |
| 24 | } |
| 25 | |
| 26 | |
| 27 | int main(int argc, char *argv[]) |
| 28 | { |
| 29 | if(argc != 2) { |
| 30 | printf("mbtk_timer_test <time>\n"); |
| 31 | return -1; |
| 32 | } |
| 33 | mbtk_log_init("radio", "MBTK"); |
| 34 | |
| 35 | int time = atoi(argv[1]); |
| 36 | if(time > 0) { |
| 37 | mbtk_timer_set(timer_alrm_cb, time * 1000); |
| 38 | } |
| 39 | |
| 40 | fd = open(KMSG, O_WRONLY); |
| 41 | if(fd > 0) { |
| 42 | printf("Open kmsg success."); |
| 43 | } |
| 44 | |
| 45 | while(1) { |
| 46 | sleep(24 * 60 * 60); |
| 47 | } |
| 48 | |
| 49 | return 0; |
| 50 | } |
| 51 | |