Explicitly use USB I/O routines in packet code
authorKeith Packard <keithp@keithp.com>
Thu, 5 Nov 2009 05:42:51 +0000 (21:42 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 5 Nov 2009 05:42:51 +0000 (21:42 -0800)
Using the implicit stdio functions (putchar/getchar/flush) would
result in essentially random redirection of each, depending on whether
the packet code had characters available when getchar was called. This
would cause lockups in putchar.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao_packet_master.c

index d03899d..f3a024c 100644 (file)
@@ -27,7 +27,7 @@ ao_packet_getchar(void)
                        break;
                if (ao_packet_master_sleeping)
                        ao_wake_task(&ao_packet_task);
-               flush();
+               ao_usb_flush();
                ao_sleep(&ao_stdin_ready);
        }
        return c;
@@ -40,7 +40,7 @@ ao_packet_echo(void) __reentrant
        while (ao_packet_enable) {
                c = ao_packet_getchar();
                if (ao_packet_enable)
-                       putchar(c);
+                       ao_usb_putchar(c);
        }
        ao_exit();
 }
@@ -114,7 +114,7 @@ ao_packet_forward(void) __reentrant
        ao_set_monitor(0);
        ao_add_task(&ao_packet_task, ao_packet_master, "master");
        ao_add_task(&ao_packet_echo_task, ao_packet_echo, "echo");
-       while ((c = getchar()) != '~') {
+       while ((c = ao_usb_getchar()) != '~') {
                if (c == '\r') c = '\n';
                ao_packet_putchar(c);
        }