From 57917601b7e27c4aa554939ec7f3e46ca0d0d572 Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Tue, 12 Jan 2016 17:29:46 +1100 Subject: [PATCH] Expose extended reset info via node.bootreason(). --- app/modules/node.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/modules/node.c b/app/modules/node.c index b10a02c0..967e85cf 100644 --- a/app/modules/node.c +++ b/app/modules/node.c @@ -472,8 +472,20 @@ static int node_setcpufreq(lua_State* L) // Lua: code = bootreason() static int node_bootreason (lua_State *L) { + struct rst_info *ri = system_get_rst_info (); lua_pushnumber (L, rtc_get_reset_reason ()); - return 1; + lua_pushnumber (L, ri->reason); + if (ri->reason == REASON_EXCEPTION_RST) + { + lua_pushnumber (L, ri->epc1); + lua_pushnumber (L, ri->epc2); + lua_pushnumber (L, ri->epc3); + lua_pushnumber (L, ri->excvaddr); + lua_pushnumber (L, ri->depc); + return 7; + } + else + return 2; } // Lua: restore()