diff options
| author | Maarten van der Schrieck <maarten@thingsconnected.nl> | 2023-10-24 23:10:45 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-12-22 10:26:52 +1100 |
| commit | 91ee8ac89405b7d063f334100b7ed0394d69fe02 (patch) | |
| tree | 79041f04198ad3d913511a8fd0f4a449b734a5d7 /extmod/misc.h | |
| parent | 5d28bb4adb24094917038a506248ff7fb351ac44 (diff) | |
extmod/os_dupterm: Let mp_os_dupterm_tx_strn() return num bytes written.
In case of multiple outputs, the minimum successful write length is
returned. In line with this, in case any output has a write error, zero is
returned.
In case of no outputs, -1 is returned.
The return value can be used to assess whether writes were attempted, and
if so, whether they succeeded.
Signed-off-by: Maarten van der Schrieck <maarten@thingsconnected.nl>
Diffstat (limited to 'extmod/misc.h')
| -rw-r--r-- | extmod/misc.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/extmod/misc.h b/extmod/misc.h index 80e5b59a0..8ea51a981 100644 --- a/extmod/misc.h +++ b/extmod/misc.h @@ -39,10 +39,12 @@ bool mp_os_dupterm_is_builtin_stream(mp_const_obj_t stream); void mp_os_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t stream_attached); uintptr_t mp_os_dupterm_poll(uintptr_t poll_flags); int mp_os_dupterm_rx_chr(void); -void mp_os_dupterm_tx_strn(const char *str, size_t len); +int mp_os_dupterm_tx_strn(const char *str, size_t len); void mp_os_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc); #else -#define mp_os_dupterm_tx_strn(s, l) +static inline int mp_os_dupterm_tx_strn(const char *s, size_t l) { + return -1; +} #endif #endif // MICROPY_INCLUDED_EXTMOD_MISC_H |
