天嵌二次封装库使用手册  V2.1.2
lib_can.h
浏览该文件的文档.
1 
7 #ifndef LINUX_LIBV2_SOURCE_CAN_LIB_CAN_H_
8 #define LINUX_LIBV2_SOURCE_CAN_LIB_CAN_H_
9 
10 // Copyright 2024
11 
12 #include <linux/can.h>
13 
14 #ifdef __cplusplus
15 #define CAN_API extern "C"
16 #else
17 #define CAN_API
18 #endif
19 
25 CAN_API int check_can(const char *dev);
26 
34 CAN_API int init_can(const char * dev,int bitrate, int mode);
35 
41 CAN_API int can_open(const char *dev);
42 
50 CAN_API int can_read_data(int fd, struct can_frame* data,unsigned int timeout_ms);
51 
58 CAN_API int can_write_data(int fd, struct can_frame data);
59 
65 CAN_API int can_close(int fd);
66 
67 #endif
68 
CAN_API int check_can(const char *dev)
查询can-lib库中是否注册了can设备
CAN_API int can_open(const char *dev)
打开can设备
CAN_API int can_close(int fd)
关闭can设备
CAN_API int can_read_data(int fd, struct can_frame *data, unsigned int timeout_ms)
用于向can设备中读取数据
CAN_API int can_write_data(int fd, struct can_frame data)
用于向can设备中写入数据
CAN_API int init_can(const char *dev, int bitrate, int mode)
初始化can设备
#define CAN_API
Definition: lib_can.h:17