simh-testsetgenerator/sim_tmxr.h
Mark Pizzolato 454b706a11 Added Buffered Console Capabilities
A key capability needed to support simulators running with background
    execution is the ability to have a Telnet connected console which isn’t
    continuously connected.  This feature is called a Buffered Telnet console.
    Absolutely nothing changes for someone not interested in using the feature.
    However, if someone is interested in the feature, the following SCP
    commands are available:

         sim> SET CONSOLE TELNET=port                  ! Unchanged
         sim> SET CONSOLE TELNET=BUFFERED{=buffersize} ! buffersize defaults to 32K
         sim> SET CONSOLE TELNET=UNBUFFERED            ! restores normal behavior
         sim> SET CONSOLE TELNET=NOBUFFERED            ! synonym for UNBUFFERED
         sim> SET CONSOLE TELNET=LOG=logdestination    ! enables logging of Telnet session traffic (potentially separate from destination specified by SET CONSOLE LOG=conlogdest)
         sim> SET CONSOLE TELNET=NOLOG                 ! turns off specific logging of Telnet session

         sim> SET CONSOLE TELNET=LOG=conlogdest                ! turns on logging all console traffic (unless the telnet session logging is also specified).

    The logdestinations for any of the logging/debugging commands can
    now be:
    LOG, DEBUG, STDOUT, STDERR or any file specification (caps are not
    required, but these names are reserved to indicate the current
    destination of the specified file handles (sim_log, sim_deb,
    stdout, stderr).

    When a Console Telnet session is Buffered, a simulator will start
    (via BOOT CPU or whatever is appropriate for a particular simulator)
    without needing to have an active telnet connection.  When a Telnet
    connection comes along for the telnet port, the contents of the saved
    buffer (which wraps on overflow) are presented on the telnet session
    as output before session traffic.  This allows the connecting telnet
    client to see what happened before he connected since the likely
    reason he might be connecting to the console of a background
    simulator is to troubleshoot unusual behavior.

    The current structure has the optional ability to log the Telnet
    session separately from the simulator output (i.e. ini file command
    execution) is potentially useful when you need to review what the
    simulator may have output which may be difficult to find in and
    amongst the possibly verbose Operating system console output.
    If someone doesn’t use “SET CONSOLE TELNET=LOG=logdestination”,
    then the original strategy of logging all output to the target
    specified by “SET CONSOLE LOG=logdestination” is preserved.  Looking
    at the isolated console output might be more interesting if/when
    control flow scp commands are ever implemented (ON,GOTO, RETURN, etc.)
2011-04-15 08:43:07 -07:00

121 lines
6.4 KiB
C

/* sim_tmxr.h: terminal multiplexor definitions
Copyright (c) 2001-2008, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Robert M Supnik shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik.
Based on the original DZ11 simulator by Thord Nilson, as updated by
Arthur Krewat.
17-Jan-11 MP Added buffered line capabilities
20-Nov-08 RMS Added three new standardized SHOW routines
27-May-08 JDB Added lnorder to TMXR structure,
added tmxr_set_lnorder and tmxr_set_lnorder
14-May-08 JDB Added dptr to TMXR structure
04-Jan-04 RMS Changed TMXR ldsc to be pointer to linedesc array
Added tmxr_linemsg, logging (from Mark Pizzolato)
29-Dec-03 RMS Added output stall support, increased buffer size
22-Dec-02 RMS Added break support (from Mark Pizzolato)
20-Aug-02 RMS Added tmxr_open_master, tmxr_close_master, tmxr.port
30-Dec-01 RMS Renamed tmxr_fstatus, added tmxr_fstats
20-Oct-01 RMS Removed tmxr_getchar, formalized buffer guard,
added tmxr_rqln, tmxr_tqln
*/
#ifndef _SIM_TMXR_H_
#define _SIM_TMXR_H_ 0
#define TMXR_V_VALID 15
#define TMXR_VALID (1 << TMXR_V_VALID)
#define TMXR_MAXBUF 256 /* buffer size */
#define TMXR_GUARD 12 /* buffer guard */
struct tmln {
SOCKET conn; /* line conn */
uint32 ipad; /* IP address */
uint32 cnms; /* conn time */
int32 tsta; /* Telnet state */
int32 rcve; /* rcv enable */
int32 xmte; /* xmt enable */
int32 dstb; /* disable Tlnt bin */
int32 rxbpr; /* rcv buf remove */
int32 rxbpi; /* rcv buf insert */
int32 rxcnt; /* rcv count */
int32 txbpr; /* xmt buf remove */
int32 txbpi; /* xmt buf insert */
int32 txcnt; /* xmt count */
int32 txdrp; /* xmt drop count */
int32 txbsz; /* xmt buffer size */
int32 txbfd; /* xmt buffered flag */
FILE *txlog; /* xmt log file */
FILEREF *txlogref; /* xmt log file reference */
char *txlogname; /* xmt log file name */
char rxb[TMXR_MAXBUF]; /* rcv buffer */
char rbr[TMXR_MAXBUF]; /* rcv break */
char *txb; /* xmt buffer */
};
typedef struct tmln TMLN;
struct tmxr {
int32 lines; /* # lines */
int32 port; /* listening port */
SOCKET master; /* master socket */
TMLN *ldsc; /* line descriptors */
int32 *lnorder; /* line connection order */
DEVICE *dptr; /* multiplexer device */
char logfiletmpl[FILENAME_MAX]; /* template logfile name */
int32 buffered; /* Buffered Line Behavior and Buffer Size Flag */
};
typedef struct tmxr TMXR;
int32 tmxr_poll_conn (TMXR *mp);
void tmxr_reset_ln (TMLN *lp);
int32 tmxr_getc_ln (TMLN *lp);
void tmxr_poll_rx (TMXR *mp);
t_stat tmxr_putc_ln (TMLN *lp, int32 chr);
void tmxr_poll_tx (TMXR *mp);
t_stat tmxr_open_master (TMXR *mp, char *cptr);
t_stat tmxr_close_master (TMXR *mp);
t_stat tmxr_attach (TMXR *mp, UNIT *uptr, char *cptr);
t_stat tmxr_detach (TMXR *mp, UNIT *uptr);
t_stat tmxr_ex (t_value *vptr, t_addr addr, UNIT *uptr, int32 sw);
t_stat tmxr_dep (t_value val, t_addr addr, UNIT *uptr, int32 sw);
void tmxr_msg (SOCKET sock, char *msg);
void tmxr_linemsg (TMLN *lp, char *msg);
void tmxr_fconns (FILE *st, TMLN *lp, int32 ln);
void tmxr_fstats (FILE *st, TMLN *lp, int32 ln);
t_stat tmxr_set_log (UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat tmxr_set_nolog (UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat tmxr_show_log (FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat tmxr_dscln (UNIT *uptr, int32 val, char *cptr, void *desc);
int32 tmxr_rqln (TMLN *lp);
int32 tmxr_tqln (TMLN *lp);
t_stat tmxr_set_lnorder (UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat tmxr_show_lnorder (FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat tmxr_show_summ (FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat tmxr_show_cstat (FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat tmxr_show_lines (FILE *st, UNIT *uptr, int32 val, void *desc);
#endif