-->
Page 1 of 2

help: example for accessing ESP:getResetInfoPtr() <solved>

PostPosted: Sat Aug 22, 2015 4:38 pm
by schufti
Hi guys,

I need the info of rst_info.reason but am not fit enough to get the struct thingie right ;)

would really appreciate a relevant snippet of code.

that is how far I get:
Code: Select allvoid setup() {
  rst_info *xyz;
  Serial.begin(115200);
  xyz = ESP.getResetInfoPtr();
  Serial.println((*xyz).reason);

and I get this error:
Code: Select allmy_am2321.ino: In function 'void setup()':
my_am2321.ino:42:24: error: invalid use of incomplete type 'struct rst_info'
In file included from D:\arduino\portable\packages\esp8266\hardware\esp8266\1.6.5-1044-g170995a\cores\esp8266/Arduino.h:248:0,
                 from D:\arduino\portable\packages\esp8266\hardware\esp8266\1.6.5-1044-g170995a\libraries\SPI/SPI.h:24,
                 from my_am2321.ino:2:
D:\arduino\portable\packages\esp8266\hardware\esp8266\1.6.5-1044-g170995a\cores\esp8266/Esp.h:125:16: error: forward declaration of 'struct rst_info'
         struct rst_info * getResetInfoPtr();
                ^
invalid use of incomplete type 'struct rst_info'

thanks,
schufti

Re: help: example for accessing ESP:getResetInfoPtr() needed

PostPosted: Sat Aug 22, 2015 5:48 pm
by martinayotte
You've probably forgot some include at the top of your sketch, because it is compiling/running fine for me without any problem.
Otherwise, maybe you have multiple SDKs in your ArduinoIDE installation.

Re: help: example for accessing ESP:getResetInfoPtr() needed

PostPosted: Sun Aug 23, 2015 6:54 am
by schufti
Hi,
could you show your includes? I am on staging 1044 version with only one sdk installation (1.20.0-26-gb404fb9-2)
I tried user_interface.h but it doesn't really help ... now defaulted to define the struct myself but not yet checked if it is working (compiled ok) ...

Code: Select allstruct rst_info{
   uint32 reason;
   uint32 exccause;
   uint32 epc1;
   uint32 epc2;
   uint32 epc3;
   uint32 excvaddr;
   uint32 depc;
};
void setup() {
  rst_info *xyz;
  Serial.begin(115200);
  xyz = ESP.getResetInfoPtr();
  Serial.println((*xyz).reason);
}

void loop() {
  // put your main code here, to run repeatedly:

}


tnx,
schufti

Re: help: example for accessing ESP:getResetInfoPtr() needed

PostPosted: Sun Aug 23, 2015 8:58 am
by martinayotte
I struggled, a bit to figure out, since I had some indirect includes ...
But I figured out :

Code: Select all#include <Arduino.h>
extern "C" {
#include <user_interface.h>
}

In my case, is was indirectly included by the IRremote.h ... :o