From: Chris Hanson Date: Mon, 19 Apr 1993 08:31:05 +0000 (+0000) Subject: Add primitives to set the baud rate of a terminal. X-Git-Tag: 20090517-FFI~8385 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=728ce40cebc5d334ccd37c3cb71107a1ced6e6d1;p=mit-scheme.git Add primitives to set the baud rate of a terminal. --- diff --git a/v7/src/microcode/dosio.c b/v7/src/microcode/dosio.c index e873576e7..6dbcc0460 100644 --- a/v7/src/microcode/dosio.c +++ b/v7/src/microcode/dosio.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: dosio.c,v 1.4 1993/04/06 22:19:01 cph Exp $ +$Id: dosio.c,v 1.5 1993/04/19 08:31:05 cph Exp $ Copyright (c) 1992-93 Massachusetts Institute of Technology @@ -397,18 +397,34 @@ DEFUN (arg_baud_index, (argument), unsigned int argument) return (arg_index_integer (argument, 1)); } -unsigned long +unsigned int DEFUN (OS_terminal_get_ispeed, (channel), Tchannel channel) { return (0); } -unsigned long +unsigned int DEFUN (OS_terminal_get_ospeed, (channel), Tchannel channel) { return (0); } +void +DEFUN (terminal_state_set_ospeed, (s, b), + Ttty_state * s AND + unsigned int b) +{ + error_unimplemented_primitive (); +} + +void +DEFUN (terminal_state_set_ispeed, (s, b), + Ttty_state * s AND + unsigned int b) +{ + error_unimplemented_primitive (); +} + unsigned int DEFUN (OS_baud_index_to_rate, (index), unsigned int index) { diff --git a/v7/src/microcode/osterm.h b/v7/src/microcode/osterm.h index d84a8bf30..caacda4c9 100644 --- a/v7/src/microcode/osterm.h +++ b/v7/src/microcode/osterm.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osterm.h,v 1.9 1992/05/05 06:35:52 jinx Exp $ +$Id: osterm.h,v 1.10 1993/04/19 08:28:05 cph Exp $ -Copyright (c) 1990-1992 Massachusetts Institute of Technology +Copyright (c) 1990-93 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -40,8 +40,12 @@ MIT in each case. */ extern Tchannel EXFUN (arg_channel, (int)); extern Tchannel EXFUN (arg_terminal, (int)); -extern unsigned long EXFUN (OS_terminal_get_ispeed, (Tchannel channel)); -extern unsigned long EXFUN (OS_terminal_get_ospeed, (Tchannel channel)); +extern unsigned int EXFUN (OS_terminal_get_ispeed, (Tchannel channel)); +extern unsigned int EXFUN (OS_terminal_get_ospeed, (Tchannel channel)); +extern void EXFUN + (OS_terminal_set_ispeed, (Tchannel channel, unsigned int baud)); +extern void EXFUN + (OS_terminal_set_ospeed, (Tchannel channel, unsigned int baud)); extern unsigned int EXFUN (arg_baud_index, (unsigned int argument)); extern unsigned int EXFUN (OS_baud_index_to_rate, (unsigned int index)); extern int EXFUN (OS_baud_rate_to_index, (unsigned int rate)); diff --git a/v7/src/microcode/prosterm.c b/v7/src/microcode/prosterm.c index c98732062..3a10e22c6 100644 --- a/v7/src/microcode/prosterm.c +++ b/v7/src/microcode/prosterm.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosterm.c,v 1.12 1992/05/05 06:34:14 jinx Exp $ +$Id: prosterm.c,v 1.13 1993/04/19 08:27:48 cph Exp $ -Copyright (c) 1990-1992 Massachusetts Institute of Technology +Copyright (c) 1990-93 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -63,6 +63,20 @@ DEFINE_PRIMITIVE ("TERMINAL-GET-OSPEED", Prim_terminal_get_ospeed, 1, 1, 0) (long_to_integer (OS_terminal_get_ospeed (arg_terminal (1)))); } +DEFINE_PRIMITIVE ("TERMINAL-SET-ISPEED", Prim_terminal_set_ispeed, 2, 2, 0) +{ + PRIMITIVE_HEADER (2); + OS_terminal_set_ispeed ((arg_terminal (1)), (arg_baud_index (2))); + PRIMITIVE_RETURN (UNSPECIFIC); +} + +DEFINE_PRIMITIVE ("TERMINAL-SET-OSPEED", Prim_terminal_set_ospeed, 2, 2, 0) +{ + PRIMITIVE_HEADER (2); + OS_terminal_set_ospeed ((arg_terminal (1)), (arg_baud_index (2))); + PRIMITIVE_RETURN (UNSPECIFIC); +} + DEFINE_PRIMITIVE ("BAUD-INDEX->RATE", Prim_baud_index_to_rate, 1, 1, 0) { PRIMITIVE_HEADER (1); diff --git a/v7/src/microcode/uxterm.c b/v7/src/microcode/uxterm.c index 9c6979928..c3b0db9dc 100644 --- a/v7/src/microcode/uxterm.c +++ b/v7/src/microcode/uxterm.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: uxterm.c,v 1.21 1993/02/18 05:15:04 gjr Exp $ +$Id: uxterm.c,v 1.22 1993/04/19 08:27:29 cph Exp $ Copyright (c) 1990-1993 Massachusetts Institute of Technology @@ -120,7 +120,7 @@ DEFUN (set_terminal_state, (channel, s), Tchannel channel AND Ttty_state * s) (UX_terminal_set_state ((CHANNEL_DESCRIPTOR (channel)), s))); } -unsigned long +unsigned int DEFUN (terminal_state_get_ospeed, (s), Ttty_state * s) { #ifdef HAVE_TERMIOS @@ -136,7 +136,7 @@ DEFUN (terminal_state_get_ospeed, (s), Ttty_state * s) #endif /* not HAVE_TERMIOS */ } -unsigned long +unsigned int DEFUN (terminal_state_get_ispeed, (s), Ttty_state * s) { #ifdef HAVE_TERMIOS @@ -152,6 +152,43 @@ DEFUN (terminal_state_get_ispeed, (s), Ttty_state * s) #endif /* not HAVE_TERMIOS */ } +void +DEFUN (terminal_state_set_ospeed, (s, b), + Ttty_state * s AND + unsigned int b) +{ +#ifdef HAVE_TERMIOS + cfsetospeed ((TIO (s)), b); +#else +#ifdef HAVE_TERMIO + ((TIO (s)) -> c_cflag) = ((((TIO (s)) -> c_cflag) &~ CBAUD) | b); +#else +#ifdef HAVE_BSD_TTY_DRIVER + (s -> sg . sg_ospeed) = b; +#endif /* HAVE_BSD_TTY_DRIVER */ +#endif /* not HAVE_TERMIO */ +#endif /* not HAVE_TERMIOS */ +} + +void +DEFUN (terminal_state_set_ispeed, (s, b), + Ttty_state * s AND + unsigned int b) +{ +#ifdef HAVE_TERMIOS + cfsetispeed ((TIO (s)), b); +#else +#ifdef HAVE_TERMIO + ((TIO (s)) -> c_cflag) = + ((((TIO (s)) -> c_cflag) &~ CIBAUD) | (b << IBSHIFT)); +#else +#ifdef HAVE_BSD_TTY_DRIVER + (s -> sg . sg_ispeed) = b; +#endif /* HAVE_BSD_TTY_DRIVER */ +#endif /* not HAVE_TERMIO */ +#endif /* not HAVE_TERMIOS */ +} + int DEFUN (terminal_state_cooked_output_p, (s), Ttty_state * s) { @@ -329,7 +366,7 @@ DEFUN (terminal_state_buffered, (s, channel), #endif /* HAVE_TERMIOS or HAVE_TERMIO */ } -unsigned long +unsigned int DEFUN (OS_terminal_get_ispeed, (channel), Tchannel channel) { Ttty_state s; @@ -337,7 +374,7 @@ DEFUN (OS_terminal_get_ispeed, (channel), Tchannel channel) return (terminal_state_get_ispeed (&s)); } -unsigned long +unsigned int DEFUN (OS_terminal_get_ospeed, (channel), Tchannel channel) { Ttty_state s; @@ -345,6 +382,28 @@ DEFUN (OS_terminal_get_ospeed, (channel), Tchannel channel) return (terminal_state_get_ospeed (&s)); } +void +DEFUN (OS_terminal_set_ispeed, (channel, baud), + Tchannel channel AND + unsigned int baud) +{ + Ttty_state s; + get_terminal_state (channel, (&s)); + terminal_state_set_ispeed ((&s), baud); + set_terminal_state (channel, (&s)); +} + +void +DEFUN (OS_terminal_set_ospeed, (channel, baud), + Tchannel channel AND + unsigned int baud) +{ + Ttty_state s; + get_terminal_state (channel, (&s)); + terminal_state_set_ospeed ((&s), baud); + set_terminal_state (channel, (&s)); +} + #ifndef NO_BAUD_CONVERSION static unsigned int baud_convert [] = #ifdef _HPUX