首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用libevent的Rs232

使用libevent的Rs232
EN

Stack Overflow用户
提问于 2013-09-02 21:22:39
回答 1查看 1.3K关注 0票数 2

我正在尝试使用libevent来管理嵌入式Linux设备和pc之间的串行通信。

libevent的第一个问题。我已经在eclipse中创建了一个C项目,基本上我正在创建一些事件,这对编译器来说是可以的:

代码语言:javascript
复制
#include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <event.h>
 #include "function_test.h"
....
int main(void) {

struct event ev_sighup;  //reports that the user's terminal is disconnected
struct event ev_sigterm; //program termination
struct event ev_sigint;  // program interrupt


int rv = 0;

/* Set up libevent & signal handling */

event_init();
event_set(&ev_sighup, SIGHUP, EV_SIGNAL, peripherals_end, NULL);
event_add(&ev_sighup, NULL);
event_set(&ev_sigterm, SIGTERM, EV_SIGNAL, peripherals_end, NULL);
event_add(&ev_sigterm, NULL);
event_set(&ev_sigint, SIGINT, EV_SIGNAL, peripherals_end, NULL);
event_add(&ev_sigint, NULL);

.....

}

但是,在“function_test.c”中:

代码语言:javascript
复制
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <string.h>
#include <event.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include "function_test.h"

.....
/*serial  file descriptor */
int 232_fd= -1;


/* Event triggered when data is available  */

struct event ev_rs232read;

.....

event_set(&ev_rs232read, 232_fd, EV_READ|EV_PERSIST, readRs232, NULL);

if ((rv = event_add(&stm32_ev_read, NULL)) < 0) {
    // log error
    return RTN_ERR;
}

return RTN_OK;

}

而且迷惑的是,Eclipse没有找到event.h (只在function_test.c中),因此我得到了下面的错误:

代码语言:javascript
复制
warning: implicit declaration of function ‘event_set’
../src/function_test.c:114: error: ‘EV_READ’ undeclared (first use in this function)
../src/function_test.c:114: error: (Each undeclared identifier is reported only once
../src/function_test.c:114: error: for each function it appears in.)
../src/function_test.c:114: error: ‘EV_PERSIST’ undeclared (first use in this function)
...
EN

回答 1

Stack Overflow用户

发布于 2013-09-14 06:43:08

在使用GNU Autotools或简单的Makefile进行编译时,这个bug会重复出现吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18574350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档