Allow different connections to use different echo values, permitting
the packet link to turn off echo while the USB link still has it on.
Signed-off-by: Keith Packard <keithp@keithp.com>
char (*pollchar)(void);
void (*putchar)(char c) __reentrant;
void (*flush)(void);
char (*pollchar)(void);
void (*putchar)(char c) __reentrant;
void (*flush)(void);
+extern __xdata struct ao_stdio ao_stdios[];
extern __data int8_t ao_cur_stdio;
extern __data int8_t ao_num_stdios;
extern __data int8_t ao_cur_stdio;
extern __data int8_t ao_num_stdios;
extern __xdata uint8_t ao_stdin_ready;
extern __xdata uint8_t ao_stdin_ready;
+uint8_t
+ao_echo(void);
+
void
ao_add_stdio(char (*pollchar)(void),
void (*putchar)(char) __reentrant,
void
ao_add_stdio(char (*pollchar)(void),
void (*putchar)(char) __reentrant,
__xdata uint32_t ao_cmd_lex_u32;
__xdata char ao_cmd_lex_c;
__xdata enum ao_cmd_status ao_cmd_status;
__xdata uint32_t ao_cmd_lex_u32;
__xdata char ao_cmd_lex_c;
__xdata enum ao_cmd_status ao_cmd_status;
-static __xdata uint8_t lex_echo;
readline(void)
{
__xdata char c;
readline(void)
{
__xdata char c;
put_string("> ");
cmd_len = 0;
for (;;) {
put_string("> ");
cmd_len = 0;
for (;;) {
/* backspace/delete */
if (c == '\010' || c == '\177') {
if (cmd_len != 0) {
/* backspace/delete */
if (c == '\010' || c == '\177') {
if (cmd_len != 0) {
put_string("\010 \010");
--cmd_len;
}
put_string("\010 \010");
--cmd_len;
}
/* ^U */
if (c == '\025') {
while (cmd_len != 0) {
/* ^U */
if (c == '\025') {
while (cmd_len != 0) {
put_string("\010 \010");
--cmd_len;
}
put_string("\010 \010");
--cmd_len;
}
c = '\n';
if (c == '\n') {
c = '\n';
if (c == '\n') {
putchar('\n');
break;
}
if (cmd_len >= CMD_LEN - 2) {
putchar('\n');
break;
}
if (cmd_len >= CMD_LEN - 2) {
putchar('\007');
continue;
}
cmd_line[cmd_len++] = c;
putchar('\007');
continue;
}
cmd_line[cmd_len++] = c;
putchar(c);
}
cmd_line[cmd_len++] = '\n';
putchar(c);
}
cmd_line[cmd_len++] = '\n';
echo(void)
{
ao_cmd_hex();
echo(void)
{
ao_cmd_hex();
- lex_echo = ao_cmd_lex_i != 0;
+ if (ao_cmd_status == ao_cmd_success)
+ ao_stdios[ao_cur_stdio].echo = ao_cmd_lex_i != 0;
__code struct ao_cmds * __xdata cs;
void (*__xdata func)(void);
__code struct ao_cmds * __xdata cs;
void (*__xdata func)(void);
for (;;) {
readline();
#if HAS_CMD_FILTER
for (;;) {
readline();
#if HAS_CMD_FILTER
#define AO_NUM_STDIOS (HAS_USB + PACKET_HAS_SLAVE + USE_SERIAL_STDIN)
#define AO_NUM_STDIOS (HAS_USB + PACKET_HAS_SLAVE + USE_SERIAL_STDIN)
-static __xdata struct ao_stdio stdios[AO_NUM_STDIOS];
+__xdata struct ao_stdio ao_stdios[AO_NUM_STDIOS];
__data int8_t ao_cur_stdio;
__data int8_t ao_num_stdios;
__data int8_t ao_cur_stdio;
__data int8_t ao_num_stdios;
putchar(char c)
{
if (c == '\n')
putchar(char c)
{
if (c == '\n')
- (*stdios[ao_cur_stdio].putchar)('\r');
- (*stdios[ao_cur_stdio].putchar)(c);
+ (*ao_stdios[ao_cur_stdio].putchar)('\r');
+ (*ao_stdios[ao_cur_stdio].putchar)(c);
- if (stdios[ao_cur_stdio].flush)
- stdios[ao_cur_stdio].flush();
+ if (ao_stdios[ao_cur_stdio].flush)
+ ao_stdios[ao_cur_stdio].flush();
}
__xdata uint8_t ao_stdin_ready;
}
__xdata uint8_t ao_stdin_ready;
int8_t stdio = ao_cur_stdio;
for (;;) {
int8_t stdio = ao_cur_stdio;
for (;;) {
- c = stdios[stdio].pollchar();
+ c = ao_stdios[stdio].pollchar();
if (c != AO_READ_AGAIN)
break;
if (++stdio == ao_num_stdios)
if (c != AO_READ_AGAIN)
break;
if (++stdio == ao_num_stdios)
+uint8_t
+ao_echo(void)
+{
+ return ao_stdios[ao_cur_stdio].echo;
+}
+
void
ao_add_stdio(char (*pollchar)(void),
void (*putchar)(char),
void
ao_add_stdio(char (*pollchar)(void),
void (*putchar)(char),
{
if (ao_num_stdios == AO_NUM_STDIOS)
ao_panic(AO_PANIC_STDIO);
{
if (ao_num_stdios == AO_NUM_STDIOS)
ao_panic(AO_PANIC_STDIO);
- stdios[ao_num_stdios].pollchar = pollchar;
- stdios[ao_num_stdios].putchar = putchar;
- stdios[ao_num_stdios].flush = flush;
+ ao_stdios[ao_num_stdios].pollchar = pollchar;
+ ao_stdios[ao_num_stdios].putchar = putchar;
+ ao_stdios[ao_num_stdios].flush = flush;
+ ao_stdios[ao_num_stdios].echo = 1;