From 43413c1099fa1726e48be763c8142bd49bd9bc56 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 12 May 2009 21:44:06 +0000 Subject: [PATCH] added termios calls for device --- door_daemon/door_daemon.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/door_daemon/door_daemon.c b/door_daemon/door_daemon.c index 36707f9..6b991db 100644 --- a/door_daemon/door_daemon.c +++ b/door_daemon/door_daemon.c @@ -20,6 +20,9 @@ #include "datatypes.h" +#include +#include + #include #include #include @@ -330,6 +333,37 @@ int main_loop(int door_fd, int cmd_listen_fd) return return_value; } +int setup_tty(int fd) +{ + struct termios tmio; + + int ret = tcgetattr(fd, &tmio); + if(ret) { + log_printf(ERROR, "Error on tcgetattr(): %s", strerror(errno)); + return ret; + } + + ret = cfsetospeed(&tmio, B9600); + if(ret) { + log_printf(ERROR, "Error on cfsetospeed(): %s", strerror(errno)); + return ret; + } + + ret = cfsetispeed(&tmio, B9600); + if(ret) { + log_printf(ERROR, "Error on cfsetispeed(): %s", strerror(errno)); + return ret; + } + + ret = tcsetattr(fd, TCSANOW, &tmio); + if(ret) { + log_printf(ERROR, "Error on tcsetattr(): %s", strerror(errno)); + return ret; + } + + return 0; +} + int main(int argc, char* argv[]) { log_init(); @@ -424,6 +458,14 @@ int main(int argc, char* argv[]) log_close(); exit(-1); } + ret = setup_tty(door_fd); + if(ret) { + close(door_fd); + options_clear(&opt); + log_close(); + exit(-1); + } + int cmd_listen_fd = init_command_socket(opt.command_sock_); if(cmd_listen_fd < 0) { -- 1.7.10.4