diff options
| author | hathach <thach@tinyusb.org> | 2018-08-22 15:24:12 +0700 |
|---|---|---|
| committer | hathach <thach@tinyusb.org> | 2018-08-22 15:24:12 +0700 |
| commit | 02b1b531534400f6028c75a34bc29bc66964697e (patch) | |
| tree | 6b566401ecf3e5ce62b7ad6983bcdb556e11a488 /lib | |
| parent | fc955b1591798ec3a6b1cb3b5d28290e478a19b1 (diff) | |
| parent | 580a191cc83a4722f6208343163238d41c54981c (diff) | |
Merge branch 'master' into nrf52_dfu_touch1200
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/netutils/netutils.c | 3 | ||||
| -rw-r--r-- | lib/utils/interrupt_char.c | 5 | ||||
| -rw-r--r-- | lib/utils/interrupt_char.h | 3 |
3 files changed, 10 insertions, 1 deletions
diff --git a/lib/netutils/netutils.c b/lib/netutils/netutils.c index 073f46b19..03418d7e6 100644 --- a/lib/netutils/netutils.c +++ b/lib/netutils/netutils.c @@ -31,6 +31,7 @@ #include "py/runtime.h" #include "lib/netutils/netutils.h" +#include "supervisor/shared/translate.h" // Takes an array with a raw IPv4 address and returns something like '192.168.0.1'. mp_obj_t netutils_format_ipv4_addr(uint8_t *ip, netutils_endian_t endian) { @@ -79,7 +80,7 @@ void netutils_parse_ipv4_addr(mp_obj_t addr_in, uint8_t *out_ip, netutils_endian } else if (i > 0 && s < s_top && *s == '.') { s++; } else { - mp_raise_ValueError("invalid arguments"); + mp_raise_ValueError(translate("invalid arguments")); } } } diff --git a/lib/utils/interrupt_char.c b/lib/utils/interrupt_char.c index fca0f95b5..91ee5c80e 100644 --- a/lib/utils/interrupt_char.c +++ b/lib/utils/interrupt_char.c @@ -47,4 +47,9 @@ void mp_keyboard_interrupt(void) { #endif } +// Check to see if we've been CTRL-C'ed by autoreload or the user. +bool mp_hal_is_interrupted(void) { + return MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)); +} + #endif diff --git a/lib/utils/interrupt_char.h b/lib/utils/interrupt_char.h index ca50d4d56..e0b1db529 100644 --- a/lib/utils/interrupt_char.h +++ b/lib/utils/interrupt_char.h @@ -26,8 +26,11 @@ #ifndef MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H #define MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H +#include <stdbool.h> + extern int mp_interrupt_char; void mp_hal_set_interrupt_char(int c); void mp_keyboard_interrupt(void); +bool mp_hal_is_interrupted(void); #endif // MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H |
