GNU/Linux: Backport from 2.1.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
2021-02-12 NIIBE Yutaka <gniibe@fsij.org>
|
2021-02-12 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
Backport from 2.1.
|
||||||
* chopstx-gnu-linux.c (chopstx_create_arch): Clear TP.
|
* chopstx-gnu-linux.c (chopstx_create_arch): Clear TP.
|
||||||
|
* example-cdc-gnu-linux/usb-cdc.c (tty_recv): Cancel the input.
|
||||||
|
* example-cdc-gnu-linux/sample.c (main): Handle timeout by canceling
|
||||||
|
input.
|
||||||
|
|
||||||
2019-12-30 NIIBE Yutaka <gniibe@fsij.org>
|
2019-12-30 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,14 @@ main (int argc, const char *argv[])
|
|||||||
if (size < 0)
|
if (size < 0)
|
||||||
goto connection_loop;
|
goto connection_loop;
|
||||||
|
|
||||||
if (size == 1)
|
if (size == 0)
|
||||||
|
/* Timeout */
|
||||||
|
{
|
||||||
|
if (tty_send (tty, "\r\n", 2) < 0)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (size == 1)
|
||||||
/* Do nothing but prompt again. */
|
/* Do nothing but prompt again. */
|
||||||
break;
|
break;
|
||||||
else if (size)
|
else if (size)
|
||||||
|
|||||||
@@ -904,8 +904,18 @@ tty_recv (struct tty *t, char *buf, uint32_t *timeout)
|
|||||||
chopstx_mutex_lock (&t->mtx);
|
chopstx_mutex_lock (&t->mtx);
|
||||||
r = check_rx (t);
|
r = check_rx (t);
|
||||||
chopstx_mutex_unlock (&t->mtx);
|
chopstx_mutex_unlock (&t->mtx);
|
||||||
if (r || (timeout != NULL && *timeout == 0))
|
if (r)
|
||||||
break;
|
break;
|
||||||
|
else if (timeout != NULL && *timeout == 0)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Cancel the input. */
|
||||||
|
for (i = 0; i < t->inputline_len; i++)
|
||||||
|
tty_send (t, "\x08\x20\x08", 3);
|
||||||
|
t->inputline_len = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
chopstx_mutex_lock (&t->mtx);
|
chopstx_mutex_lock (&t->mtx);
|
||||||
|
|||||||
Reference in New Issue
Block a user