1
0
mirror of https://github.com/open-simh/simh.git synced 2026-05-03 14:49:02 +00:00

SCP: Added EXPECT and SEND commands to react to data from and inject data into the simulated console port (and other MUX ports)

Ideas based on Dave Bryan's console halt efforts.

	sim> SEND {<mux>:line} {DELAY=n,}"string"

Where <mux> is the name of the device pointed to by the TMXR structure.  If <mux>:line isn't specified, then the console device is implicitly being referenced.
Delay is optional and once set persists for subsequent SEND operations to the same device.  Delay defaults to 1000.  The DELAY value is a minimum number of instructions which must execute before the next character in the provided string will be injected to the console port.  The DELAY value has effect between the characters delivered as well.  "string" requires quotes and within the quoted string, common C escape character syntax is available (\r\r\t, etc.).

Each device (console, and each line in each mux) has a separate value for DELAY.

An arbitrary number of 'expect' conditions can be defined.  The command syntax is:

              sim> EXPECT {<mux>:line} {[cnt]} "matchstring" {actioncommand {; actioncommand ...}}

Where <mux> is the name of the device pointed to by the TMXR structure.  If <mux>:line isn't specified, then the console device is implicitly being referenced.
"matchstring" requires quotes and within the quoted string, common C escape character syntax is available (\r\r\t, etc.).  The quotes used can be single or double quotes, but the closing quote must match the opening quote.  The match string might be extended to allow the use of perl style regular expressions in the "matchstring" when a -R switch is specified on the command line.

              sim> EXPECT "Enter Color: "  SEND "Red\r"; g

A specific 'expect' condition can be removed with:

              sim> NOEXPECT {<mux>:line} "matchstring"

All 'expect' conditions can be removed with:

              sim> NOEXPECT {<mux>:line}

'expect' conditions can be examined with:

              sim> SHOW EXPECT {<mux>:line}

Expect rules are one-shots (i.e. they disappear once a match has occurred) unless they are explicitly described as persistent with the -P switch.
The -C switch is available when defining expect rules.  The effect of a rule defined with the -C flag is that when an expect match occurs for that rule, ALL rules are cleared for that device (console or <mux>:line).
This commit is contained in:
Mark Pizzolato
2014-10-14 10:49:24 -07:00
parent d0865d37f5
commit 02e90de6a4
7 changed files with 1030 additions and 62 deletions

18
scp.h
View File

@@ -82,6 +82,8 @@ t_stat call_cmd (int32 flag, char *ptr);
t_stat on_cmd (int32 flag, char *ptr);
t_stat noop_cmd (int32 flag, char *ptr);
t_stat assert_cmd (int32 flag, char *ptr);
t_stat send_cmd (int32 flag, char *ptr);
t_stat expect_cmd (int32 flag, char *ptr);
t_stat help_cmd (int32 flag, char *ptr);
t_stat spawn_cmd (int32 flag, char *ptr);
t_stat echo_cmd (int32 flag, char *ptr);
@@ -114,9 +116,12 @@ char *get_sim_opt (int32 opt, char *cptr, t_stat *st);
char *get_glyph (const char *iptr, char *optr, char mchar);
char *get_glyph_nc (const char *iptr, char *optr, char mchar);
char *get_glyph_quoted (const char *iptr, char *optr, char mchar);
t_value get_uint (char *cptr, uint32 radix, t_value max, t_stat *status);
t_value get_uint (const char *cptr, uint32 radix, t_value max, t_stat *status);
char *get_range (DEVICE *dptr, char *cptr, t_addr *lo, t_addr *hi,
uint32 rdx, t_addr max, char term);
t_stat sim_decode_quoted_string (const char *iptr, uint8 *optr, uint32 *osize);
char *sim_encode_quoted_string (const uint8 *iptr, uint32 size);
void fprint_buffer_string (FILE *st, const uint8 *buf, uint32 size);
t_value strtotv (const char *cptr, char **endptr, uint32 radix);
t_stat fprint_val (FILE *stream, t_value val, uint32 rdx, uint32 wid, uint32 fmt);
t_stat sim_print_val (t_value val, uint32 radix, uint32 width, uint32 format);
@@ -140,6 +145,17 @@ uint32 sim_brk_test (t_addr bloc, uint32 btyp);
void sim_brk_clrspc (uint32 spc);
char *sim_brk_clract (void);
void sim_brk_setact (const char *action);
t_stat sim_send_input (SEND *snd, uint8 *data, size_t size, uint32 delay);
t_stat sim_show_send_input (FILE *st, SEND *snd);
t_bool sim_send_poll_data (SEND *snd, t_stat *stat);
t_stat sim_set_expect (EXPECT *exp, char *cptr);
t_stat sim_set_noexpect (EXPECT *exp, char *cptr);
t_stat sim_exp_set (EXPECT *exp, const char *match, int32 cnt, int32 switches, char *act);
t_stat sim_exp_clr (EXPECT *exp, const char *match);
t_stat sim_exp_clrall (EXPECT *exp);
t_stat sim_exp_show (FILE *st, EXPECT *exp, const char *match);
t_stat sim_exp_showall (FILE *st, EXPECT *exp);
t_stat sim_exp_check (EXPECT *exp, uint8 data);
char *match_ext (char *fnam, char *ext);
t_stat show_version (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);
t_stat set_dev_debug (DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);