Rs232使用libevent

时间:2013-09-02 13:22:39

标签: serial-port libevent

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

libevent的第一个问题。我在eclipse中创建了一个C项目,主要是我正在创建一些事件,编译器可以使用:

#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”中:

#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中),因此我得到了下一个错误:

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)
...

1 个答案:

答案 0 :(得分:0)

在使用GNU Autotools编译或仅使用简单的Makefile时,是否会重复此错误?