machine.reset_cause() not working

Hi,

I am attempting to utilize both the watchdog feature and the machine.reset_reason() without any luck.

I am initializing the watchdog based on the documentation and this is working properly:
dog = machine.WDT(timeout=5000, response=machine.HARD_RESET)

In my test I am triggering a watchdog event after a few seconds. Upon reboot, I read out the reset cause like so:
reset_reason = machine.reset_cause()
print("reset reason: " + str(reset_reason))

As a result, reset_reason is always printing 0 even when it is a triggered watchdog event.

I found the list of constants that the machine.reset_cause returns, and I would thing I would return a 4 or a 5 if the cause was a watchdog reset.

https://www.digi.com/resources/documentation/digidocs/90002219/Default.htm#reference/r_constants_reset.htm?TocPath=Machine%2520module%257CReset-cause%257C_____1

Am I doing something wrong that is causing machine.reset_cause() to not return the correct value?

I am operating XB3-24 Digimesh 300B

Thank you.

1 Like

I suspect you have not implemented one of the needed functions.

import machine
help(machine)

Same here,

import time
import xbee
import machine

print(“reset_cause”, machine.reset_cause())
time.sleep_ms(1000)
machine.soft_reset()

above main.py continually prints:

Loading /flash/main.mpy…
Running bytecode…
reset_cause 0
soft reboot

despite help(machine) saying that:
HARD_RESET – 0
WDT_RESET – 1
SOFT_RESET – 6

I would have expected machine.reset_cause() to return 6

1 Like

Matthew,

I emailed tech support who confirmed this is a bug that is specific to Digimesh 300B firmware (it works as expected on 802.15.4 and ZigBee.

It was suppose to be escalated to engineering for them to fix in a future firmware release, but I am not aware of a implemented fix yet :frowning:

Joseph

Similar problem here

Product family: XB3-24
Function set: Digi XBee3 Zigbee 3.0 TH
Firmware version: 100D

help(machine) output:

PWRON_RESET – 4
HARD_RESET – 3
WDT_RESET – 5
SOFT_RESET – 6
BROWNOUT_RESET – 11
LOCKUP_RESET – 9

When the device is restarted by WDT, machine.reset_cause() returns 6 instead of 5

PS: Firmware version 1010 is available but I didn’t have a chance to update, but from the change log I can deduct that this bug isn’t fixed