Tue Mar 7 00:23:47 1995 Stu Grossman (grossman@cygnus.com)
+ * serial.h ser-go32.c ser-go32-para.c ser-mac.c ser-tcp.c
+ ser-unix.c: Add SERIAL_SETSTOPBITS to set the number of stopbits
+ (needed for IDP board?!?!?).
+
* defs.h utils.c remote-hms.c remote-pa.c remote.c: Fix defs and
usage of fputc_unfiltered and putchar_unfiltered. Eliminate
putc_unfiltered (it's superfluous).
return 0;
}
+static int
+go32_setstopbits (scb, num)
+ serial_t scb;
+ int num;
+{
+ return 0;
+}
+
static void
go32_close (scb)
serial_t scb;
go32_print_tty_state,
go32_noflush_set_tty_state,
go32_setbaudrate,
+ go32_setstopbits,
};
void
if (port->baudrate != rate)
{
int x;
+ unsigned char cfcr;
x = dos_baudconv (rate);
if (x <= 0)
}
disable ();
+ cfcr = inb (port, com_cfcr);
+
outb(port, com_cfcr, CFCR_DLAB);
outb(port, com_dlbl, x & 0xff);
outb(port, com_dlbh, x >> 8);
- outb(port, com_cfcr, CFCR_8BITS);
+ outb(port, com_cfcr, cfcr);
port->baudrate = rate;
enable ();
}
return 0;
}
+static int
+dos_setstopbits (scb, num)
+ serial_t scb;
+ int num;
+{
+ struct dos_ttystate *port = &ports[scb->fd];
+ unsigned char cfcr;
+
+ disable ();
+ cfcr = inb (port, com_cfcr);
+
+ switch (num)
+ {
+ case SERIAL_1_STOPBITS:
+ outb (port, com_cfcr, cfcr & ~CFCR_STOPB);
+ break;
+ case SERIAL_1_AND_A_HALF_STOPBITS:
+ case SERIAL_2_STOPBITS:
+ outb (port, com_cfcr, cfcr | CFCR_STOPB);
+ break;
+ default:
+ enable ();
+ return 1;
+ }
+ enable ();
+
+ return 0;
+}
static int
dos_write (scb, str, len)
dos_print_tty_state,
dos_noflush_set_tty_state,
dos_setbaudrate,
+ dos_setstopbits,
};
return 0;
}
+static int
+mac_set_stop_bits (scb, num)
+ serial_t scb;
+ int num;
+{
+ return 0;
+}
+
int first_mac_write = 0;
static int
mac_print_tty_state,
mac_noflush_set_tty_state,
mac_set_baud_rate,
+ mac_set_stop_bits,
};
void
static int wait_for PARAMS ((serial_t scb, int timeout));
static int tcp_readchar PARAMS ((serial_t scb, int timeout));
static int tcp_setbaudrate PARAMS ((serial_t scb, int rate));
+static int tcp_setstopbits PARAMS ((serial_t scb, int num));
static int tcp_write PARAMS ((serial_t scb, const char *str, int len));
/* FIXME: static void tcp_restore PARAMS ((serial_t scb)); */
static void tcp_close PARAMS ((serial_t scb));
return 0; /* Never fails! */
}
+static int
+tcp_setstopbits(scb, num)
+ serial_t scb;
+ int num;
+{
+ return 0; /* Never fails! */
+}
+
static int
tcp_write(scb, str, len)
serial_t scb;
tcp_print_tty_state,
tcp_noflush_set_tty_state,
tcp_setbaudrate,
+ tcp_setstopbits,
};
void
return set_tty_state (scb, &state);
}
+static int
+hardwire_setstopbits(scb, num)
+ serial_t scb;
+ int num;
+{
+ struct hardwire_ttystate state;
+ int newbit;
+
+ if (get_tty_state(scb, &state))
+ return -1;
+
+ switch (num)
+ {
+ case SERIAL_1_STOPBITS:
+ newbit = 0;
+ break;
+ case SERIAL_1_AND_A_HALF_STOPBITS:
+ case SERIAL_2_STOPBITS:
+ newbit = 1;
+ break;
+ default:
+ return 1;
+ }
+
+#ifdef HAVE_TERMIOS
+ if (!newbit)
+ state.termios.c_cflag &= ~CSTOPB;
+ else
+ state.termios.c_cflag |= CSTOPB; /* two bits */
+#endif
+
+#ifdef HAVE_TERMIO
+ if (!newbit)
+ state.termio.c_cflag &= ~CSTOPB;
+ else
+ state.termio.c_cflag |= CSTOPB; /* two bits */
+#endif
+
+#ifdef HAVE_SGTTY
+ return 0; /* sgtty doesn't support this */
+#endif
+
+ return set_tty_state (scb, &state);
+}
+
static int
hardwire_write(scb, str, len)
serial_t scb;
hardwire_print_tty_state,
hardwire_noflush_set_tty_state,
hardwire_setbaudrate,
+ hardwire_setstopbits,
};
void
int (*noflush_set_tty_state)
PARAMS ((serial_t, serial_ttystate, serial_ttystate));
int (*setbaudrate) PARAMS ((serial_t, int rate));
+ int (*setstopbits) PARAMS ((serial_t, int num));
};
/* Add a new serial interface to the interface list */
#define SERIAL_SETBAUDRATE(SERIAL_T, RATE) ((SERIAL_T)->ops->setbaudrate((SERIAL_T), RATE))
+/* Set the number of stop bits to the value specified. Returns 0 for success,
+ -1 for failure. */
+
+#define SERIAL_1_STOPBITS 1
+#define SERIAL_1_AND_A_HALF_STOPBITS 2 /* 1.5 bits, snicker... */
+#define SERIAL_2_STOPBITS 3
+
+#define SERIAL_SETSTOPBITS(SERIAL_T, NUM) ((SERIAL_T)->ops->setstopbits((SERIAL_T), NUM))
+
/* Write LEN chars from STRING to the port SERIAL_T. Returns 0 for
success, non-zero for failure. */