static int hardwire_send_break PARAMS ((serial_t));
static int hardwire_setstopbits PARAMS ((serial_t, int));
+void _initialize_ser_hardwire PARAMS ((void));
+
+#ifdef __CYGWIN__
+extern void (*ui_loop_hook) PARAMS ((int));
+#endif
+
/* Open up a real live device for serial I/O */
static int
}
static int
-get_tty_state(scb, state)
+get_tty_state (scb, state)
serial_t scb;
struct hardwire_ttystate *state;
{
#ifdef HAVE_TERMIOS
- extern int errno;
-
if (tcgetattr(scb->fd, &state->termios) < 0)
return -1;
serial_t scb;
int timeout;
{
+#ifndef __CYGWIN__
scb->timeout_remaining = 0;
+#endif
#ifdef HAVE_SGTTY
{
to wait, or -1 to wait forever. Use timeout of 0 to effect a poll. Returns
char if successful. Returns SERIAL_TIMEOUT if timeout expired, EOF if line
dropped dead, or SERIAL_ERROR for any other error (see errno in that case). */
-
static int
-hardwire_readchar(scb, timeout)
+hardwire_readchar (scb, timeout)
serial_t scb;
int timeout;
{
int status;
+#ifdef __CYGWIN__
+ int t;
+#endif
if (scb->bufcnt-- > 0)
return *scb->bufp++;
+#ifdef __CYGWIN__
+ if (timeout > 0)
+ timeout++;
+#endif
+
while (1)
{
+#ifdef __CYGWIN__
+ t = timeout == 0 ? 0 : 1;
+ scb->timeout_remaining = timeout < 0 ? timeout : timeout - t;
+ status = wait_for (scb, t);
+
+ /* -2 means disable timer */
+ if (ui_loop_hook)
+ ui_loop_hook (-2);
+#else
status = wait_for (scb, timeout);
-
+#endif
if (status < 0)
return status;
timeout = scb->timeout_remaining;
continue;
}
+#ifdef __CYGWIN__
+ else if (scb->timeout_remaining < 0)
+ continue;
+#endif
else
return SERIAL_TIMEOUT;
}