Skip to content

Commit 8964228

Browse files
committed
silently return when watchdog isn't active
1 parent 11cf031 commit 8964228

File tree

3 files changed

+23
-53
lines changed

3 files changed

+23
-53
lines changed

locale/circuitpython.pot

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ msgstr ""
184184
msgid "%q must be <= %d"
185185
msgstr ""
186186

187-
#: py/argcheck.c
188-
msgid "%q must be >= %d"
187+
#: ports/espressif/common-hal/watchdog/WatchDogTimer.c
188+
msgid "%q must be <= %u"
189189
msgstr ""
190190

191-
#: ports/espressif/common-hal/analogbufio/BufferedIn.c
192-
msgid "%q must be array of type 'H'"
191+
#: py/argcheck.c
192+
msgid "%q must be >= %d"
193193
msgstr ""
194194

195195
#: shared-bindings/analogbufio/BufferedIn.c
@@ -200,6 +200,10 @@ msgstr ""
200200
msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'"
201201
msgstr ""
202202

203+
#: ports/espressif/common-hal/analogbufio/BufferedIn.c
204+
msgid "%q must be array of type 'H'"
205+
msgstr ""
206+
203207
#: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c
204208
#: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c
205209
msgid "%q must be of type %q or %q, not %q"
@@ -1154,10 +1158,6 @@ msgstr ""
11541158
msgid "Initial set pin state conflicts with initial out pin state"
11551159
msgstr ""
11561160

1157-
#: ports/espressif/common-hal/watchdog/WatchDogTimer.c
1158-
msgid "Initialization failed due to lack of memory"
1159-
msgstr ""
1160-
11611161
#: shared-bindings/bitops/__init__.c
11621162
#, c-format
11631163
msgid "Input buffer length (%d) must be a multiple of the strand count (%d)"
@@ -1229,7 +1229,8 @@ msgstr ""
12291229
msgid "Interrupt error."
12301230
msgstr ""
12311231

1232-
#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c
1232+
#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c
1233+
#: shared-bindings/digitalio/DigitalInOut.c
12331234
#: shared-bindings/displayio/EPaperDisplay.c
12341235
msgid "Invalid %q"
12351236
msgstr ""
@@ -1523,10 +1524,6 @@ msgstr ""
15231524
msgid "No in or out in program"
15241525
msgstr ""
15251526

1526-
#: shared-bindings/aesio/aes.c
1527-
msgid "No key was specified"
1528-
msgstr ""
1529-
15301527
#: shared-bindings/time/__init__.c
15311528
msgid "No long integer support"
15321529
msgstr ""
@@ -1822,11 +1819,6 @@ msgstr ""
18221819
msgid "Pull not used when direction is output."
18231820
msgstr ""
18241821

1825-
#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c
1826-
#: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c
1827-
msgid "RAISE mode is not implemented"
1828-
msgstr ""
1829-
18301822
#: ports/raspberrypi/common-hal/countio/Counter.c
18311823
msgid "RISE_AND_FALL not available on this chip"
18321824
msgstr ""
@@ -2350,20 +2342,10 @@ msgstr ""
23502342
msgid "WARNING: Your code filename has two extensions\n"
23512343
msgstr ""
23522344

2353-
#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c
23542345
#: ports/nrf/common-hal/watchdog/WatchDogTimer.c
2355-
#: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c
23562346
msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET"
23572347
msgstr ""
23582348

2359-
#: shared-bindings/watchdog/WatchDogTimer.c
2360-
msgid "WatchDogTimer is not currently running"
2361-
msgstr ""
2362-
2363-
#: shared-bindings/watchdog/WatchDogTimer.c
2364-
msgid "WatchDogTimer.mode cannot be changed once set to WatchDogMode.RESET"
2365-
msgstr ""
2366-
23672349
#: py/builtinhelp.c
23682350
#, c-format
23692351
msgid ""
@@ -3044,8 +3026,8 @@ msgid "extra positional arguments given"
30443026
msgstr ""
30453027

30463028
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c
3047-
#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c
3048-
#: shared-module/gifio/GifWriter.c
3029+
#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/gifio/OnDiskGif.c
3030+
#: shared-bindings/synthio/__init__.c shared-module/gifio/GifWriter.c
30493031
msgid "file must be a file opened in byte mode"
30503032
msgstr ""
30513033

@@ -4087,10 +4069,7 @@ msgstr ""
40874069
msgid "syntax error in uctypes descriptor"
40884070
msgstr ""
40894071

4090-
#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c
4091-
#: ports/espressif/common-hal/watchdog/WatchDogTimer.c
40924072
#: ports/nrf/common-hal/watchdog/WatchDogTimer.c
4093-
#: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c
40944073
msgid "timeout duration exceeded the maximum supported value"
40954074
msgstr ""
40964075

@@ -4291,10 +4270,6 @@ msgstr ""
42914270
msgid "value_count must be > 0"
42924271
msgstr ""
42934272

4294-
#: ports/espressif/common-hal/watchdog/WatchDogTimer.c
4295-
msgid "watchdog not initialized"
4296-
msgstr ""
4297-
42984273
#: shared-bindings/is31fl3741/FrameBuffer.c
42994274
msgid "width must be greater than zero"
43004275
msgstr ""

ports/espressif/common-hal/watchdog/WatchDogTimer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, mp_floa
100100
}
101101

102102
if ((uint64_t)new_timeout > UINT32_MAX) {
103-
mp_raise_ValueError_varg(translate("%q must be <= %d"), MP_QSTR_timeout, UINT32_MAX);
103+
mp_raise_ValueError_varg(translate("%q must be <= %u"), MP_QSTR_timeout, UINT32_MAX);
104104
}
105105
self->timeout = new_timeout;
106106

shared-bindings/watchdog/WatchDogTimer.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,18 @@
5050
//|
5151

5252
//| def __init__(self) -> None:
53-
//| """Not currently dynamically supported. Access the sole instance through `microcontroller.watchdog`."""
53+
//| """Access the sole instance through `microcontroller.watchdog`."""
5454
//| ...
5555

5656
//| def feed(self) -> None:
5757
//| """Feed the watchdog timer. This must be called regularly, otherwise
58-
//| the timer will expire."""
58+
//| the timer will expire. Silently does nothing if the watchdog isn't active."""
5959
//| ...
6060
STATIC mp_obj_t watchdog_watchdogtimer_feed(mp_obj_t self_in) {
6161
watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in);
62-
watchdog_watchdogmode_t current_mode = common_hal_watchdog_get_mode(self);
63-
64-
if (current_mode == WATCHDOGMODE_NONE) {
65-
mp_raise_ValueError(translate("WatchDogTimer is not currently running"));
62+
if (common_hal_watchdog_get_mode(self) != WATCHDOGMODE_NONE) {
63+
common_hal_watchdog_feed(self);
6664
}
67-
68-
common_hal_watchdog_feed(self);
6965
return mp_const_none;
7066
}
7167
STATIC MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_feed_obj, watchdog_watchdogtimer_feed);
@@ -89,7 +85,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_deinit_obj, watchdog_wat
8985

9086
//| timeout: float
9187
//| """The maximum number of seconds that can elapse between calls
92-
//| to feed()"""
88+
//| to `feed()`"""
9389
STATIC mp_obj_t watchdog_watchdogtimer_obj_get_timeout(mp_obj_t self_in) {
9490
watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in);
9591
return mp_obj_new_float(common_hal_watchdog_get_timeout(self));
@@ -114,17 +110,16 @@ MP_PROPERTY_GETSET(watchdog_watchdogtimer_timeout_obj,
114110
//| mode: WatchDogMode
115111
//| """The current operating mode of the WatchDogTimer `watchdog.WatchDogMode`.
116112
//|
117-
//| Setting a WatchDogMode activates the WatchDog::
113+
//| Setting a `WatchDogMode` activates the WatchDog::
118114
//|
119-
//| import microcontroller
120-
//| import watchdog
115+
//| from microcontroller import watchdog as w
116+
//| from watchdog import WatchDogMode
121117
//|
122-
//| w = microcontroller.watchdog
123118
//| w.timeout = 5
124-
//| w.mode = watchdog.WatchDogMode.RAISE
119+
//| w.mode = WatchDogMode.RESET
125120
//|
126121
//|
127-
//| Once set, the WatchDogTimer will perform the specified action if the timer expires."""
122+
//| Once set, the `WatchDogTimer` will perform the specified action if the timer expires."""
128123
//|
129124
STATIC mp_obj_t watchdog_watchdogtimer_obj_get_mode(mp_obj_t self_in) {
130125
watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in);

0 commit comments

Comments
 (0)