summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/serial/serial_base.cc
diff options
context:
space:
mode:
authorschodet2005-03-13 20:27:45 +0000
committerschodet2005-03-13 20:27:45 +0000
commit8b904537173b2e6573dac605c957b17bed9ed75e (patch)
tree0be120d4fe527e7e55c565087afdc2f710e854a7 /2005/i/robert/src/serial/serial_base.cc
parentfcfd616f76345787a8eb1318e482ab1076d50039 (diff)
Utilisation de FdSet::wait.
Correction du bug de parsage de tty sur SerialDev.
Diffstat (limited to '2005/i/robert/src/serial/serial_base.cc')
-rw-r--r--2005/i/robert/src/serial/serial_base.cc38
1 files changed, 4 insertions, 34 deletions
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 <sys/types.h>
-#include <sys/time.h>
+#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);
}