7 #ifndef LINUX_LIBV2_SOURCE_UART_LIB_UART_H_ 8 #define LINUX_LIBV2_SOURCE_UART_LIB_UART_H_ 12 #define ERROR_NOSUPPORT -5 14 #define ERROR_INPARA -3 15 #define ERROR_TIMEOUT -2 20 #define UART_API extern "C" 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)
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秒