aboutsummaryrefslogtreecommitdiff
path: root/example-fs-bb48
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2016-05-23 17:42:01 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2016-05-23 17:42:01 +0900
commit72c3d59555d5c8359518ce9c141b40018f87e3ce (patch)
tree2ab4a03284556dac9d15bef731d11ec319918f6b /example-fs-bb48
parent8ba91f5db6ec51174eed0da5563a0a6ea9ed3136 (diff)
Change example-fs-bb48
Diffstat (limited to 'example-fs-bb48')
-rw-r--r--example-fs-bb48/sample.c6
-rw-r--r--example-fs-bb48/usb-cdc.c9
2 files changed, 13 insertions, 2 deletions
diff --git a/example-fs-bb48/sample.c b/example-fs-bb48/sample.c
index 2935709..5966577 100644
--- a/example-fs-bb48/sample.c
+++ b/example-fs-bb48/sample.c
@@ -184,7 +184,7 @@ main (int argc, const char *argv[])
if (size < 0)
break;
- if (usec)
+ if (size)
{
unsigned int value;
@@ -215,6 +215,8 @@ main (int argc, const char *argv[])
{
int i;
+ size--;
+
crc32_init ();
s[0] = hexchar (size >> 4);
s[1] = hexchar (size & 0x0f);
@@ -239,6 +241,8 @@ main (int argc, const char *argv[])
}
else
{
+ size--;
+
s[0] = hexchar (size >> 4);
s[1] = hexchar (size & 0x0f);
s[2] = ':';
diff --git a/example-fs-bb48/usb-cdc.c b/example-fs-bb48/usb-cdc.c
index b412cf1..afbaff3 100644
--- a/example-fs-bb48/usb-cdc.c
+++ b/example-fs-bb48/usb-cdc.c
@@ -544,6 +544,7 @@ tty_input_char (struct tty *t, int c)
switch (c)
{
case 0x0d: /* Control-M */
+ t->inputline[t->inputline_len++] = '\n';
tty_echo_char (t, 0x0d);
tty_echo_char (t, 0x0a);
t->flag_input_avail = 1;
@@ -577,7 +578,7 @@ tty_input_char (struct tty *t, int c)
}
break;
default:
- if (t->inputline_len < sizeof (t->inputline))
+ if (t->inputline_len < sizeof (t->inputline) - 1)
{
tty_echo_char (t, c);
t->inputline[t->inputline_len++] = c;
@@ -784,6 +785,12 @@ check_rx (void *arg)
return 0;
}
+/*
+ * Returns -1 on connection close
+ * 0 on timeout.
+ * >0 length of the inputline (including final \n)
+ *
+ */
int
tty_recv (struct tty *t, uint8_t *buf, uint32_t *timeout)
{