1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <fcntl.h>
12 #include "hdf_log.h"
13 
14 #define HDF_LOG_TAG hello_uart
15 #define INFO_SIZE   16
16 
main(void)17 int main(void)
18 {
19     int ret;
20     int fd;
21     const char info[INFO_SIZE] = {" HELLO UART! "};
22 
23     fd = open("/dev/uartdev-5", O_RDWR);
24     if (fd < 0) {
25         HDF_LOGE("uartdev-5 open failed %d", fd);
26         return -1;
27     }
28     ret = write(fd, info, INFO_SIZE);
29     if (ret != 0) {
30         HDF_LOGE("write uartdev-5 ret is %d", ret);
31     }
32     ret = close(fd);
33     if (ret != 0) {
34         HDF_LOGE("uartdev-5 close failed %d", fd);
35         return -1;
36     }
37     return ret;
38 }