[gnu.emacs] Flow Control on DECServer 200s

ROBERTS%UORNSRL.BITNET@MITVMA.MIT.EDU (12/14/88)

I'm running GNU Emacs 18.52.2 under VAX/VMS 4.7 on one of several vaxen
connected through a terminal server (DECServer 200).  When emacs starts up
or restarts after being suspended, the terminal server is put in pasthru
mode, but flow control is not disabled.  I can disable flow control
(XON/XOFF) on the server manually, but this is undesirable due to the need
to turn it back on later.

[the reason I _need_ flow control is that I'm writing some graphics
applications for our HDS3200 (Human Design Systems) terminals which can
emulate vt52/vt100/vt220/tek4014 as well as native 4096x4096 resolution
graphics.  the graphics data comes too fast and needs flow control turned
on both on the server and the terminal to work properly -- I've tried
various permutations with both off or only one on and it doesn't work.  the
graphics come out garbled]

My question is who knows what sort of magic is used to get the server to
switch to pasthru mode --- does it do this by sensing the terminal's
condition?  Is there a way to disable flow control _on_the_server_ by an
appropriate termcap entry?

Roland Roberts                        BITNET: roberts@uornsrl.bitnet
  Nuclear Structure Research Lab    INTERNET: rbr4@db2.cc.rochester.edu
  271 East River Road                   UUCP: rochester!ur-cc!rbr4
  Rochester, NY  14267                  AT&T: (716) 275-8962

usenet@cps3xx.UUCP (Usenet file owner) (12/14/88)

in article <8812140754.AA08784@prep.ai.mit.edu>, ROBERTS%UORNSRL.BITNET@MITVMA.MIT.EDU says:
> 
> I'm running GNU Emacs 18.52.2 under VAX/VMS 4.7 on one of several vaxen
> connected through a terminal server (DECServer 200).  When emacs starts up
> or restarts after being suspended, the terminal server is put in pasthru
> mode, but flow control is not disabled.  I can disable flow control
> (XON/XOFF) on the server manually, but this is undesirable due to the need
> to turn it back on later.
> 
> [the reason I _need_ flow control is that I'm writing some graphics
Why just include the lines:

(global-unset-key "\C-s")
(global-unset-key "\C-q")

in your .emacs file? Granted you lose isearch-forward that way, but you
can you something like:

(global-set-key "\C-z" 'isearch-forward)

That's how I've always done it in a DEC environment.

If I've misunderstood the problem, please let me know what the proper
solution turns out to be.

John H. Lawitzke      UUCP: ...rutgers!mailrus!frith!fciiho!jhl
Michigan Farm Bureau        ...decvax!purdue!mailrus!frith!fciiho!jhl
Insurance Group             ...uunet!frith!jhl
"What?!? Real computing at an insurance company?!? AND in Michigan!?!"

LUSGR%LEHICDC1.BITNET@MITVMA.MIT.EDU (Steve Roseman) (12/14/88)

>I'm running GNU Emacs 18.52.2 under VAX/VMS 4.7 on one of several vaxen
>connected through a terminal server (DECServer 200).  When emacs starts up
>or restarts after being suspended, the terminal server is put in pasthru
>mode, but flow control is not disabled.  I can disable flow control
>(XON/XOFF) on the server manually, but this is undesirable due to the need
>to turn it back on later.
>...
>My question is who knows what sort of magic is used to get the server to
>switch to pasthru mode --- does it do this by sensing the terminal's
>condition?  Is there a way to disable flow control _on_the_server_ by an
>appropriate termcap entry?

>Roland Roberts                        BITNET: roberts@uornsrl.bitnet
>  Nuclear Structure Research Lab    INTERNET: rbr4@db2.cc.rochester.edu
>  271 East River Road                   UUCP: rochester!ur-cc!rbr4
>  Rochester, NY  14267                  AT&T: (716) 275-8962

    If anyone knows how, I would like to hear.  However, I don't think it
is possible.  The LAT/VMS V4.7 manual states (pg 4-1)  "Flow control to the
physical device is handled by the terminal server instead of the host.  A
seperate flow control mechanism exists between the server and host.  The
following terminal characteristics do not apply to LAT terminals:
    TT$M_READSYNCH
    TT$M_TTSYNCH"

    We leave flow control disabled on the servers (in order to use Emacs),
and the user must manually enable it whenever data overflow problems occur.
Yes, that's a hassle.

Steve Roseman
Lehigh University Computing Center
LUSGR@LEHICDC1.BITNET

jr@bbn.com (John Robinson) (12/14/88)

In article <1312@cps3xx.UUCP>, usenet@cps3xx (Usenet file owner) writes:
>in article <8812140754.AA08784@prep.ai.mit.edu>, ROBERTS%UORNSRL.BITNET@MITVMA.MIT.EDU says:
>> 
>> I'm running GNU Emacs 18.52.2 under VAX/VMS 4.7 on one of several vaxen
>> connected through a terminal server (DECServer 200).  When emacs starts up
>> or restarts after being suspended, the terminal server is put in pasthru
>> mode, but flow control is not disabled.  I can disable flow control
>> (XON/XOFF) on the server manually, but this is undesirable due to the need
>> to turn it back on later.
>Why just include the lines:
>
>(global-unset-key "\C-s")
>(global-unset-key "\C-q")
>
>in your .emacs file? Granted you lose isearch-forward that way, but you
>can you something like:
>
>(global-set-key "\C-z" 'isearch-forward)

I have appended the file I send out from time to time to address the
cope-with-the-flow-control-losing-world's problems; it is a little
more elaborate than the above suggestion.  This list hasn't seen it
yet, at any rate.

I think the original poster asked for some VMS help; though I have
neer worked with the term servers, I suspect VMS somehow has the
ability to manipulate you terminal line's settings.  That avoids
having to have a "non-standard" keyboard setup and may be the best
approach; your "emacs" command would be a macro that (1) turns off
server flowcontrol, (2) executes emacs and (3) turns it back on before
returning to DCL.

Now maybe VMS/decserver aren't that smart.  I think there may be a way
to store the terminal-end incantations that turn flow control on and
off under function keys in the HDS terminal, and then get the terminal
to send these sequences back towards the terminal server by a host
command (really!  the HDS people made their terminal too clever for
its own good).  Then you just add the control sequences to the
terminal's init and exit termcap strings, and voila.
--------
GNU emacs (version 18.48 and later) provides several options for
coping with terminals or front-ends that insist on using flow control
characters.  Listed in estimated order of preference.

1.  Have Emacs run in CBREAK mode with the kernel handling flow
control.  Issue (set-input-mode nil t) from .emacs.  It is now
necessary to find other keys to bind to the commands isearch-forward
and quoted-insert.  Traditional nominees are C-^ and C-\.  There are
two ways to get this effect:

  1a.  Use the keyboard-translate-table to cause C-^ and C-\ to be
  received by Emacs as though C-S and C-Q were typed.  Emacs
  (except at its very lowest level) never knows that the characters
  typed were anything but C-S and C-Q, so the use of these keys inside
  isearch still works - typing C-^ while incremental searching will
  move the cursor to the next match, etc.  Here's some code for this:

  (setq keyboard-translate-table (make-string 128 0))
  (let ((i 0))
    (while (< i 128)
      (aset keyboard-translate-table i i)
      (setq i (1+ i))))

  (aset keyboard-translate-table ?\^\\ ?\^s)
  (aset keyboard-translate-table ?\^^ ?\^q)

  1b.  Simply rebind the keys C-^ and C-\ to isearch-forward and
  quoted-insert.  To get continued searches inside isearch it is also
  necessary to set search-repeat-char to C-^.

2.  Don't use CBREAK mode, and cause C-S and C-Q to be bound to a null
command.  The problem with this is that whatever sent the flow control
characters is apt to be falling behind the characters being sent to
it, and so what finds its way to the terminal screen will not in
general be what is intended.  It will be still be necessary to find
other keys to bind to isearch-forward and quoted-insert; see 1a and 1b
above.

Here is a suitable null command:

  (defun noop ()
    "Do nothing; return nil."
    (interactive))

3.  Don't use CBREAK mode, and global-unset-key the keys C-S and C-Q.
This is similar to #2, except that the flow control characters will
probably cause beeps or visible bells.

Note that, if the terminal is the source of flow control characters
and kernel flow control handling is enabled, it will not in general be
necessary to send padding characters as specified in a termcap or
terminfo entry.  It may be possible to customize a termcap entry to
provide better Emacs performance on the assumption that flow control
is in use.  This effect can also be simulated by announcing (with
stty(1) or its equivalent) that the terminal is running at a very slow
speed, provided the terminal is not directly wired to the host.

Some Background

This section attempts to answer the question "Why does emacs choose to
use flow-control characters in its command character set?"  For
another view, please read the comments on flow control in
emacs/INSTALL from the distribution.

Flow control was not necessary for most terminals once upon a time, so
use of C-S and C-Q for command characters was reasonable.  Emacs, for
economy of keystrokes and portability, chose to use the control
characters in the ASCII character set for its functions, and tried to
use mnemonic assignments (S for search, Q for quote).  There are other
(albeit less common in practice) ways to do flow control that preserve
transparency of the character stream.

Once emacs' precedent was established, it was too hard to undo.  One
might even argue that emacs' use of these control characters predates
their use by terminals and front-ends for flow control.  Notice also
that the latter use is ONLY a de-facto standard.  In fact, on the
model 33 teletype with a paper tape punch (which is VERY old), they
were used for the host to turn the punch on and off!

So which usage is "right", emacs' or the terminal/front-end
manufacturer's?  This is a rhetorical (or religious) question; it
has no simple answer.
--
/jr
jr@bbn.com or bbn!jr