GNU/Linux: Fix the example to cancel the input on timeout.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
2021-02-10 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* example-cdc-gnu-linux/usb-cdc.c (tty_recv): Cancel the input.
|
||||
|
||||
* chopstx.c (chx_recv_irq): Bug fix when no waiter.
|
||||
|
||||
* chopstx-gnu-linux.c (chopstx_create_arch): Fix ARGC of
|
||||
|
||||
@@ -176,7 +176,7 @@ chx_idle (void)
|
||||
else
|
||||
{
|
||||
tp_next = chx_recv_irq (sig);
|
||||
/* Exit when there is no waiter and it's INT or TERM. */
|
||||
/* Exit when there is no waiter and it's INT or TERM. */
|
||||
if (tp_next == NULL
|
||||
&& (sig == SIGINT || sig == SIGTERM))
|
||||
exit (1);
|
||||
|
||||
@@ -180,12 +180,12 @@ main (int argc, const char *argv[])
|
||||
goto connection_loop;
|
||||
|
||||
if (size == 0)
|
||||
/* Timeout */
|
||||
{
|
||||
if (tty_send (tty, "\r\n", 2) < 0)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
/* Timeout */
|
||||
{
|
||||
if (tty_send (tty, "\r\n", 2) < 0)
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
else if (size == 1)
|
||||
/* Do nothing but prompt again. */
|
||||
break;
|
||||
|
||||
@@ -905,7 +905,17 @@ tty_recv (struct tty *t, char *buf, uint32_t *timeout)
|
||||
r = check_rx (t);
|
||||
chopstx_mutex_unlock (&t->mtx);
|
||||
if (r || (timeout != NULL && *timeout == 0))
|
||||
break;
|
||||
{
|
||||
/* Cancel the input. */
|
||||
for (i = 0; i < t->inputline_len; i++)
|
||||
{
|
||||
tty_echo_char (t, 0x08);
|
||||
tty_echo_char (t, 0x20);
|
||||
tty_echo_char (t, 0x08);
|
||||
}
|
||||
t->inputline_len = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
chopstx_mutex_lock (&t->mtx);
|
||||
|
||||
Reference in New Issue
Block a user