summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-11-05 13:09:32 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-11-05 13:09:32 +0200
commiteb2b875f3eeb90bcf56e17e7912267ccbd77d9fd (patch)
tree462b28694cb2fdf8d71bcc3e65308873e21fc55b
parent088a10434777d6f6eb87309cfac14d4ffca4b40e (diff)
downloadobexd-eb2b875f3eeb90bcf56e17e7912267ccbd77d9fd.tar.gz
Use cfmakeraw() to setup the tty termios settings.
Without this patch the gadget serial drivers produce easily HUP's and ERR's on the opened tty file descriptor.
-rw-r--r--src/main.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 455065f..24a002c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -65,21 +65,17 @@ static void tty_init(int service, const gchar *root_path,
struct server *server;
struct termios options;
gint fd;
+ glong flags;
fd = open(devnode, O_RDWR);
if (fd < 0)
return;
- fcntl(fd, F_SETFL, 0);
+ flags = fcntl(fd, F_GETFL);
+ fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
tcgetattr(fd, &options);
-
- options.c_cflag |= (CLOCAL | CREAD);
- options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
- options.c_oflag &= ~OPOST;
- options.c_cc[VMIN] = 0;
- options.c_cc[VTIME] = 10;
-
+ cfmakeraw(&options);
tcsetattr(fd, TCSANOW, &options);
server = g_malloc0(sizeof(struct server));