Merge pull request #924 from DiUS/rst-info

Expose extended reset info via node.bootreason().
This commit is contained in:
Terry Ellison 2016-01-12 13:17:21 +00:00
commit 2ff1324d2e
1 changed files with 13 additions and 1 deletions

View File

@ -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()