Change example-cdc
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
2016-05-23 NIIBE Yutaka <gniibe@fsij.org>
|
2016-05-23 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
* example-cdc/usb-cdc.c (tty_input_char): Include newline.
|
||||||
|
* example-cdc/sample.c: Handle newline.
|
||||||
|
|
||||||
* example-fs-bb48/usb-cdc.c: Update from example-cdc.
|
* example-fs-bb48/usb-cdc.c: Update from example-cdc.
|
||||||
* example-fs-bb48/tty.h: Likewise.
|
* example-fs-bb48/tty.h: Likewise.
|
||||||
* example-fs-bb48/sample.c: Follow the change.
|
* example-fs-bb48/sample.c: Follow the change.
|
||||||
|
|||||||
@@ -142,8 +142,10 @@ main (int argc, const char *argv[])
|
|||||||
if (size < 0)
|
if (size < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (usec)
|
if (size)
|
||||||
{
|
{
|
||||||
|
size--;
|
||||||
|
|
||||||
s[0] = hexchar (size >> 4);
|
s[0] = hexchar (size >> 4);
|
||||||
s[1] = hexchar (size & 0x0f);
|
s[1] = hexchar (size & 0x0f);
|
||||||
s[2] = ':';
|
s[2] = ':';
|
||||||
|
|||||||
@@ -548,6 +548,7 @@ tty_input_char (struct tty *t, int c)
|
|||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 0x0d: /* Control-M */
|
case 0x0d: /* Control-M */
|
||||||
|
t->inputline[t->inputline_len++] = '\n';
|
||||||
tty_echo_char (t, 0x0d);
|
tty_echo_char (t, 0x0d);
|
||||||
tty_echo_char (t, 0x0a);
|
tty_echo_char (t, 0x0a);
|
||||||
t->flag_input_avail = 1;
|
t->flag_input_avail = 1;
|
||||||
@@ -581,7 +582,7 @@ tty_input_char (struct tty *t, int c)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (t->inputline_len < sizeof (t->inputline))
|
if (t->inputline_len < sizeof (t->inputline) - 1)
|
||||||
{
|
{
|
||||||
tty_echo_char (t, c);
|
tty_echo_char (t, c);
|
||||||
t->inputline[t->inputline_len++] = c;
|
t->inputline[t->inputline_len++] = c;
|
||||||
@@ -791,6 +792,12 @@ check_rx (void *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns -1 on connection close
|
||||||
|
* 0 on timeout.
|
||||||
|
* >0 length of the inputline (including final \n)
|
||||||
|
*
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
tty_recv (struct tty *t, uint8_t *buf, uint32_t *timeout)
|
tty_recv (struct tty *t, uint8_t *buf, uint32_t *timeout)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user