b.liu | 8583dce | 2024-04-03 13:30:08 +0800 | [diff] [blame^] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <sys/types.h> |
| 4 | #include <sys/stat.h> |
| 5 | #include <fcntl.h> |
| 6 | #include <string.h> |
| 7 | #include <unistd.h> |
| 8 | #include <pthread.h> |
| 9 | #include <sys/socket.h> |
| 10 | #include <semaphore.h> |
| 11 | #include <linux/netlink.h> |
| 12 | |
| 13 | #include <lynq/lynq-qser-usb.h> |
| 14 | |
| 15 | sem_t usbplug_sem; |
| 16 | void do_get_adb_state(int nargs, char **argv) |
| 17 | { |
| 18 | |
| 19 | int ret = 0; |
| 20 | |
| 21 | ret = qser_get_usb_usermode_adb_state(); |
| 22 | if (ret < 0) |
| 23 | { |
| 24 | printf("get adb state fail,ret:%d \n", ret); |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | printf("adb state:%d, %s\n", ret, ((ret == 0) ? "off" : "on")); |
| 29 | } |
| 30 | |
| 31 | void do_get_net_state(int nargs, char **argv) |
| 32 | { |
| 33 | |
| 34 | int ret = 0; |
| 35 | |
| 36 | ret = qser_get_usb_usermode_net_state(); |
| 37 | if (ret < 0) |
| 38 | { |
| 39 | printf("get net state fail,ret:%d \n", ret); |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | printf("net state:%d, %s\n", ret, ((ret == 0) ? "off" : "on")); |
| 44 | } |
| 45 | |
| 46 | int main(int argc, char *argv[]) |
| 47 | { |
| 48 | sem_init(&usbplug_sem, 0, 0); |
| 49 | do_get_adb_state(argc, argv); |
| 50 | do_get_net_state(argc, argv); |
| 51 | sem_post(&usbplug_sem); |
| 52 | return 0; |
| 53 | } |