From 8b904537173b2e6573dac605c957b17bed9ed75e Mon Sep 17 00:00:00 2001 From: schodet Date: Sun, 13 Mar 2005 20:27:45 +0000 Subject: Utilisation de FdSet::wait. Correction du bug de parsage de tty sur SerialDev. --- 2005/i/robert/src/serial/serial_base.cc | 38 ++++----------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) (limited to '2005/i/robert/src/serial/serial_base.cc') diff --git a/2005/i/robert/src/serial/serial_base.cc b/2005/i/robert/src/serial/serial_base.cc index e2fe250..b92a6b0 100644 --- a/2005/i/robert/src/serial/serial_base.cc +++ b/2005/i/robert/src/serial/serial_base.cc @@ -23,10 +23,7 @@ // // }}} #include "serial_base.hh" -#include "utils/errno_exception.hh" - -#include -#include +#include "utils/fd_set.hh" /// Constructeur. SerialBase::SerialBase (void) @@ -80,35 +77,8 @@ SerialBase::putchar (int c) bool SerialBase::wait (int timeout/*-1*/) { - fd_set fds; - int r; - // Setup fd_set. - FD_ZERO (&fds); - FD_SET (fdIn_, &fds); - if (timeout == -1) - { - // Without timeout. - r = select (FD_SETSIZE, &fds, 0, 0, 0); - } - else - { - // With timeout. - struct timeval tv; - tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout % 1000) * 1000; - r = select (FD_SETSIZE, &fds, 0, 0, &tv); - } - switch (r) - { - case -1: - // Error. - throw errno_exception (errno); - case 0: - // Timeout. - return false; - default: - // Data availlable. - return true; - } + FdSet fds; + fds.set (fdIn_); + return fds.wait (timeout); } -- cgit v1.2.3