Browse Source

Expose extended reset info via node.bootreason().

Johny Mattsson 8 years ago
parent
commit
57917601b7
1 changed files with 13 additions and 1 deletions
  1. 13 1
      app/modules/node.c

+ 13 - 1
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()