[Linux服务器] linux can 通信程序,Linux CAN通信

665 0
Honkers 2025-9-30 02:07:27 | 显示全部楼层 |阅读模式

Linux CAN通信

实现了Linux下的CAN通信——初始化,发两个送和接收(采用队列形式),使用两个线程,还有一个超时响应目前未写。接收部分使用select实现。

#ifndef _CAN_H_

#define _CAN_H_

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include "can_queue.h"

#include "type.h"

#ifndef AF_CAN

#define AF_CAN 29

#endif

#ifndef PF_CAN

#define PF_CAN AF_CAN

#endif

typedef enum

{

CAN_PORT_0 = 0, // can0

CAN_PORT_1, // can1

}can_port_t ;

typedef struct

{

char *name;

int fd;

fd_set fdsr;

pthread_t send_thread;

pthread_t recv_thread;

pthread_t time_thread;

can_queue_t *send_queue; // 接受和发送的队列

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行