当前位置: 首页 > news >正文

个人软件网站域名镇江网站建设制作

个人软件网站域名,镇江网站建设制作,阿里巴巴运营技巧,广东如何做企业网站设计Linux CAN通信 实现了Linux下的CAN通信——初始化#xff0c;发两个送和接收#xff08;采用队列形式#xff09;#xff0c;使用两个线程#xff0c;还有一个超时响应目前未写。接收部分使用select实现。 #ifndef _CAN_H_ #define _CAN_H_#include stdio.h #incl…Linux CAN通信 实现了Linux下的CAN通信——初始化发两个送和接收采用队列形式使用两个线程还有一个超时响应目前未写。接收部分使用select实现。 #ifndef _CAN_H_ #define _CAN_H_#include stdio.h #include sys/ioctl.h #include arpa/inet.h #include net/if.h #include linux/socket.h #include linux/can.h #include linux/can/error.h #include linux/can/raw.h #include fcntl.h #include unistd.h #include stdlib.h #include string.h #include errno.h #include time.h #include pthread.h #include can_queue.h #include type.h#ifndef AF_CAN #define AF_CAN 29 #endif #ifndef PF_CAN #define PF_CAN AF_CAN #endiftypedef enum {CAN_PORT_0 0, // can0CAN_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; // 接受和发送的队列can_queue_t *recv_queue; } can_t;void *CanInit(int arg);#endif /* _CAN_H_ */#include can.hstatic can_t *can_init(int name) {int ret;struct sockaddr_can addr;struct ifreq ifr;struct can_filter rfilter[1];can_t *current (can_t *)malloc(sizeof(can_t));current-fd Socket(PF_CAN, SOCK_RAW, CAN_RAW);sprintf(ifr.ifr_name, can%d, name);current-name (char *)malloc(6);memset(current-name, 0, 6);sprintf(current-name, can%d, name);ret ioctl(current-fd, SIOCGIFINDEX, ifr);if(ret 0){exit(0);}addr.can_family AF_CAN;addr.can_ifindex ifr.ifr_ifindex;Bind(current-fd, (struct sockaddr *)addr, sizeof(addr));rfilter[0].can_id 0x2;rfilter[0].can_mask 0;Setsockopt(current-fd, SOL_CAN_RAW, CAN_RAW_FILTER, rfilter, sizeof(rfilter));return current; }static void *can_send_thread(void *arg) {int ret;can_t *current arg;can_frame_t frame;uint8_t read_ret 0;while(1){Write(current-fd, frame, sizeof(frame));read_ret current-send_queue-can_read(current-send_queue, frame);if(CAN_OK read_ret){ret Write(current-fd, frame, sizeof(frame));usleep(1200);}usleep(100);}return NULL; }static void *can_recv_thread(void *arg) {int ret, i;can_frame_t frame;struct timeval tv;fd_set rset;can_t *current arg;while (1){tv.tv_sec 0;tv.tv_usec 200;FD_ZERO(rset);FD_SET(current-fd, rset);ret select(current-fd 1, rset, NULL, NULL, NULL);if (0 ret){return NULL;}ret read(current-fd, frame, sizeof(frame));if (ret sizeof(frame)){return NULL;}if (current-recv_queue-can_write(current-recv_queue, frame) CAN_ERROR){}}return NULL; }void *CanInit(int arg) {can_t *current can_init(arg);current-recv_queue CanQueueInit(CAN_RECV_QUEUE_SIZE);current-send_queue CanQueueInit(CAN_SEND_QUEUE_SIZE);pthread_create(current-send_thread, NULL, can_send_thread, (void *)current);pthread_create(current-recv_thread, NULL, can_recv_thread, (void *)current); }
http://www.zqtcl.cn/news/75130/

相关文章:

  • 网站建设合同定义网站策划与建设阶段的推广
  • 采网站建设WordPress动画随音乐变化
  • 网站维护托管网站有情链接怎么做
  • 做网站公司怎么选网站建设企业网站制作
  • 微信网站模版下载冬奥会建设官方网站
  • 夏天做啥网站致富谁能分享个小网站啊
  • 免费医院网页模板seo网站优化培
  • 毕设代做网站郑州百度网站推广
  • 网站网址查询工具用来做收录的网站
  • 广东品牌网站建设服务机构wordpress 瀑布流 插件
  • 做毕业设计网站需要的工具如何设计网站的首页
  • 做网站点子最新国际新闻10条简短
  • 青州做网站的网络公司广州网站建设服务哪家好
  • 上海哪家公司提供专业的网站建设公司网站管理制定的作用
  • 青柠直播免费版嘉兴网站排名优化报
  • 个人网站开发主要问题php网站开发技术前景
  • 简述网页与网站的区别php网站开发文章管理系统
  • 在网站上做播放视频广告是否违法邳州徐州网站开发
  • 南京网站开发联系南京乐识湘潭做网站价格咨询磐石网络
  • 做推广任务的网站网页布局的几种方法
  • 福建省建设注册中心网站惠州小程序搭建
  • 平台网站做数据维护需要多久1号网站建设 高端网站建设
  • 福州网站建设技术支持微信公众平台注册不了
  • 响应式网站开发现状长沙公司有哪些
  • 有没有网站做设计可以赚钱调查问卷网页html代码
  • 网站建设20推广吗网站建设
  • 移动宽带续费网上营业厅seo推广优化收费
  • 鹰潭市网站建设网站模板破解版
  • 金融网站素材动态ip建网站
  • 网站优化改动怎么做成都高端网站建设那家好