Open happytm opened 3 years ago
I doubled the allocation for both but having same problem.
Thanks.
I even tried almost empty function like below:
void probeRequest(WiFiEvent_t event, WiFiEventInfo_t info) {
processData();
}
And ESP32 panic as soon as it reaches processData();
It is surprising that processData work fine when it is called from loop but behave differently when called from other places.
My error message in arduino serial console is as follows:
Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (network_event)
Core 1 register dump:
PC : 0x4008c018 PS : 0x00060236 A0 : 0x40086e14 A1 : 0x3ffb85d0
A2 : 0x00000001 A3 : 0x3ffc8728 A4 : 0x3ffc8728 A5 : 0x00000001
A6 : 0x00060220 A7 : 0x00000000 A8 : 0x80085428 A9 : 0x3ffb8670
A10 : 0x3ff000e0 A11 : 0x00000001 A12 : 0x3ffbfbe8 A13 : 0x00000001
A14 : 0x00060223 A15 : 0x00000000 SAR : 0x00000008 EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Backtrace: 0x4008c018:0x3ffb85d0 0x40086e11:0x3ffb86b0 0x4018a69b:0x3ffb86f0 0x4018a772:0x3ffb8710 0x400871ce:0x3ffb8730 0x400876d1:0x3ffb8750 0x401918a3:0x3ffb87c0 0x4011cefc:0x3ffb87f0 0x40119b81:0x3ffb8820 0x40119fdb:0x3ffb8850 0x4011a591:0x3ffb88f0 0x4011ca3d:0x3ffb8950 0x40118da1:0x3ffb89a0 0x40187dfd:0x3ffb8ad0 0x4000bcdd:0x3ffb8af0 0x40148a75:0x3ffb8b10 0x40116e63:0x3ffb8b30 0x4019941b:0x3ffb8b90 0x400d59c9:0x3ffb8bb0 0x400f1b8d:0x3ffb8be0 0x400f460f:0x3ffb8c30 0x40108031:0x3ffb8c80 0x4010e111:0x3ffb8d10 0x4010e16e:0x3ffb8d30 0x4010f5b4:0x3ffb8d50 0x4010f741:0x3ffb8d90 0x401100de:0x3ffb8db0 0x40112b3d:0x3ffb8dd0 0x40105961:0x3ffb8f30 0x40107c91:0x3ffb9110 0x40107e1e:0x3ffb9260 0x40107e61:0x3ffb92a0 0x4010da2b:0x3ffb92d0 0x400d2108:0x3ffb9320 0x400d264b:0x3ffb9340 0x400d2d60:0x3ffb93b0 0x400d19c5:0x3ffb93f0 0x400d4509:0x3ffb9440 0x400d45e4:0x3ffb9530 0x4008993e:0x3ffb9560
"Debug exception reason: Stack canary watchpoint triggered (network_event) " this message in particular definitely points to proberequest function.
Is there any work around this problem?
Thanks.
Hi, my opinion is that this is happening because processData has a lot of calls to Sqlite API functions and each call takes time in the event handler is holding things up.
Is it possible to set a flag in the event handler and return immediately and call processData from loop() function based on the flag and reset the flag after that? You may have to call the MQTT loop() and client poll() function at each step of processData() so as not to loose packets from MQTT or WiFi.
That's what I was thinking about doing. Somehow use loop to trigger processData() but I am not sure how to achieve that.
Thanks.
Just add a flag such as int triggerProcessData = 0
on top. Set the value to 1 in the event handler and add if (triggerProcessData) { processData(); triggerProcessData = 0; }
in loop function.
Thank you very much for your help.
You are absolutely on spot diagnosing the problem and providing accurate solution for it.
ESP32 is happy now and does not panic anymore with insert statement.
My new issue is Websocket server code in loop is blocking one which does not allow any code until websocket client is connected. I am going to raise issue at their repository to find out way around it. My loop looks like below:
void loop() {
if (triggerProcessData == 1) {
processData();
triggerProcessData = 0;
}
#if MQTT
broker.loop(); // Don't forget to add loop for every broker and clients
myClient.loop();
#endif
#if WEBSOCKETS
//auto client = WSserver.accept();
//client.onMessage(handle_message);
//processData();
static auto next=millis(); // The next line is an efficient delay() replacement
if (millis() > next){next += 10000;} //let's give time to SQLITE3 to prepare data requested from client.
//while (client.available()) {
//client.poll();
//}
#endif
} // End of loop
This line "auto client = WSserver.accept();" in code above is blocking one so it is stuck there.
Thanks again.
I finally got the issue with websockets blocking the code in loop resolved with library's creator.
Now everything works as expected. So this issue is resolved.
Thank you for your help and patience.
Hi Arun ,
I was able to implement your library with Asyncwebserver, Websockets and TinyMQTT and it works as expected. I was able to insert Fake data created by function called processData() and also I can query data from database using same function by requesting data from websocket client.
When I call processData() function from loop it works fine but when I call same function from another place (line 542) it panics and decoded message looks like following:
My sketch is at: https://github.com/happytm/BatteryNode/blob/master/test/SQLite3_Proberequest.ino
Can you please help me resolve this issue?