天嵌二次封装库使用手册  V2.1.2
lib_uart.h
浏览该文件的文档.
1 
7 #ifndef LINUX_LIBV2_SOURCE_UART_LIB_UART_H_
8 #define LINUX_LIBV2_SOURCE_UART_LIB_UART_H_
9 
10 // Copyright 2024
11 
12 #define ERROR_NOSUPPORT -5
13 #define ERROR_SYS -4
14 #define ERROR_INPARA -3
15 #define ERROR_TIMEOUT -2
16 #define ERROR_FAIL -1
17 #define ERROR_OK 0
18 
19 #ifdef __cplusplus
20 #define UART_API extern "C"
21 #else
22 #define UART_API
23 #endif
24 
33  UART_API int uart_init(char *dev, int nBaud, int nBits, char nEvent, int nStop);
34 
42  UART_API int uart_write_data(int fd, char *buff, int len);
43 
52  UART_API int uart_read_data(int fd, char *buff, int len, int timeout_ms);
53 
58  UART_API void uart_close(int fd);
59 
65  UART_API int uart_open(char *dev_name);
66 
74  UART_API int uart_write(int fd, char *buff, int len);
75 
83  UART_API int uart_read(int fd, char *buff, int len);
84 
85  UART_API int receive_uart(char *dev_name, char *buff, int len, int timeout_ms, int rx_time_ms);
86 
87 #endif
UART_API int uart_open(char *dev_name)
打开串口
UART_API int uart_init(char *dev, int nBaud, int nBits, char nEvent, int nStop)
初始化串口
UART_API void uart_close(int fd)
关闭串口
UART_API int uart_write(int fd, char *buff, int len)
向串口写数据,,参数和使用方法与 uart_write_data 函数一样
UART_API int receive_uart(char *dev_name, char *buff, int len, int timeout_ms, int rx_time_ms)
#define UART_API
Definition: lib_uart.h:22
UART_API int uart_write_data(int fd, char *buff, int len)
向串口写数据
UART_API int uart_read_data(int fd, char *buff, int len, int timeout_ms)
读取串口信息
UART_API int uart_read(int fd, char *buff, int len)
读取串口信息,默认读取超时时间为1秒