-->
Page 1 of 2

Help for using system_get_rst_info

PostPosted: Wed Sep 09, 2015 3:45 pm
by smily77
Can someone help me using the system_get_rst_info function

I'm not really experianced in C and don't know how I need to call the function with a *variable. My code so far:
Code: Select allextern "C" {
  #include "user_interface.h"
}
 struct rstInfo {
  uint32 reason;
  uint32 exxccause;
  uint32 epc1;
  uint32 epc2;
  uint32 epc3;
  uint32 excvaddr;
  uint32 depc;
 };

void setup() {
 Serial.begin(9600);
 Serial.println();
 //Prototype rst_info* system_get_rst_info(void)
????? = system_get_rst_info(); ??????
 Serial.println(rstInfo.reason);
}

void loop() {
  delay(1);
}


Thanks for help

Re: Help for using system_get_rst_info

PostPosted: Wed Sep 09, 2015 4:20 pm
by martinayotte
There is already a wrapper for it in Esp.h, so you can useit as follow :

Code: Select all#include <Esp.h>

void setup() {
 Serial.begin(9600);
 Serial.println();
 rst_info* rinfo = ESP.getResetInfoPtr();
 Serial.println(rinfo->reason);
}

Re: Help for using system_get_rst_info

PostPosted: Thu Sep 10, 2015 6:12 am
by Sifourquier
but in c is

struct rst_info* info;
info = system_get_rst_info();
int reason=rstInfo->reason;
//or
int reason=*rstInfo.reason;

}

Re: Help for using system_get_rst_info

PostPosted: Thu Sep 10, 2015 8:52 am
by martinayotte
It is a pointer, so, as I stated above : rinfo->reason