From 661e2b6a731da3b4b309b331bfbd40a29a69d7e9 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Sun, 8 May 2022 20:19:20 -0400 Subject: add ability to read from USB serial --- watch-library/shared/watch/watch.h | 8 ++++++++ watch-library/shared/watch/watch_private.h | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'watch-library/shared') diff --git a/watch-library/shared/watch/watch.h b/watch-library/shared/watch/watch.h index 1dd8e7f7..b307feca 100644 --- a/watch-library/shared/watch/watch.h +++ b/watch-library/shared/watch/watch.h @@ -76,4 +76,12 @@ */ bool watch_is_buzzer_or_led_enabled(void); +/** @brief Reads up to len bytes from the USB serial. + * @param file ignored, you can pass in 0 + * @param ptr pointer to a buffer of at least len bytes + * @param len the number of bytes you wish to read, max 256. + * @return The number of bytes read, or zero if no bytes were read. + */ +int read(int file, char *ptr, int len); + #endif /* WATCH_H_ */ \ No newline at end of file diff --git a/watch-library/shared/watch/watch_private.h b/watch-library/shared/watch/watch_private.h index 7bb91d1f..9d55bc21 100644 --- a/watch-library/shared/watch/watch_private.h +++ b/watch-library/shared/watch/watch_private.h @@ -44,7 +44,8 @@ void _watch_enable_usb(void); // this function ends up getting called by printf to log stuff to the USB console. int _write(int file, char *ptr, int len); -// this method could be overridden to read stuff from the USB console? but no need rn. -int _read(void); +// i thought this would be called by gets but it doesn't? anyway it does get called by read() +// so that's our mechanism for reading data from the USB serial console. +int _read(int file, char *ptr, int len); #endif -- cgit v1.2.3