Add primitives to set the baud rate of a terminal.
authorChris Hanson <org/chris-hanson/cph>
Mon, 19 Apr 1993 08:31:05 +0000 (08:31 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 19 Apr 1993 08:31:05 +0000 (08:31 +0000)
v7/src/microcode/dosio.c
v7/src/microcode/osterm.h
v7/src/microcode/prosterm.c
v7/src/microcode/uxterm.c

index e873576e7bba20542010f8860c9f19370da2aab3..6dbcc04603d9b461570bb196602b2d47787fd83e 100644 (file)
@@ -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)
 {
index d84a8bf30ec6ff1f722fcaf6acd94227e5ddd361..caacda4c9fe28103a234ff8b29c3ba0c64f3d441 100644 (file)
@@ -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));
index c98732062529109351d53223cee4df731c3db895..3a10e22c693cac035d74adce0155c7cff6d98e47 100644 (file)
@@ -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);
index 9c6979928d1133cf55f3557078d94b3711c76abc..c3b0db9dcfd13796943a2545e38e8306bba41354 100644 (file)
@@ -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)));
 }
 \f
-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 */
 }
 \f
-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