-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue when trying to add an Object to a nested array #493
Comments
If I instead choose by JsonObject& nested = variablesArray.createNestedObject(); I get a wdt reset error with no stack so I can't debug it and I can't then put the data in the JsonObject& nested because of wdt reset error. |
Hello @Alexpelillo, Can you share the source code? Regards, |
and the functions loadConfig, saveConfig:
aaaand the json file (short one) (Object with nested array, which has nested array with nested Objects)
|
Sorry for comments being in Spanish, and for the Json, it would have more devices and more variables in each device, but that will do. All the functions like loading the Json, modifying it, saving it, deleting a variable or deleting a device ( like variablesArray.removeAt() ), are working in some way (with delays so the ESP8266 does not reset, with rubbish at starting of the JSON so it reads it corrupt but it does not do a thing with it...) Since it's a little secret project I have in mind i would like to not share the entire .ino file. I did the stack trace decoding and it marks me in the starting of add() function from the JsonArray at your library) ((JsonArray&) config_devices["Devices"][dispositivo_actual]["Vars"]).add(tempBuffer.parseObject(json_s));
|
I'm sorry, there is too much code 😢 |
If you can please make an example to add a variable to my JSON... You don't have to store it in memory just get the JSON to a progmem string, parse it and when you have it try to add a variable or add a device or just add a blank object. Just focus please on the JSON:
|
Found out also that if I load the pointer to variablesArray, I can print it well so it's not an issue of getting the right pointer:
I get by serial:
But if I uncomment the createnested.... even if it's blank, I get exception (9), |
Well that's very interesting 👍 Then, please try to add the following line before including ArduinoJson: #define ARDUINOJSON_ENABLE_ALIGNMENT 1
#include <ArduinoJson.h> It enables aligned allocation. |
I added that define, and with CreateNestedObject inside the array the stack trace is the following: (Exc. 9)
|
With variable.add(jobject) the stack trace is the following (Exception 9 too):
Gotta say that it creates the variable nested (before adding it to the array), and I can print it to Serial even if I load the config with the array of variables and all that stuff BEFORE i print it to Serial, so there is no pointer corruption, I believe.
|
I'm sorry but I don't manage to reproduce the issue on my ESP8266. I'm using ESP8266 core for Arduino, maybe the problem is related to NodeMCU. |
But have you been able to create a new variable inside that json array that I provided? If so, just copy here the part of the code that has been able to add the variable. |
Any news? Is it related to the library? |
No progress, I'm sorry. |
I'll try to make a smaller piece of code and I'll paste it here. |
@Alexpelillo Any progress? |
Hi BBlanchon, I can't thank you enough for making this library, but as I'm trying to make a system that loads a structure from memory filesystem (Developing on esp8266 NodeMcu with Arduino IDE), the only resort that i'm encountering right now is this one:
The structure is like this:
{"Devices":[
{"Device":"Circutor CVM-mini",
"Vars":[
{"VrName":"VRMS",
"VrAddr":"20"}]}}]
With more than 1 device and with more than 1 variable each. I am able to load and store from memory, and delete variables too with array.removeAt()... (will try further to delete devices) But I can't create variables inside the vars array. Tried with varArray.createNestedObject() and then filling the Object with data, and tried with first creating the Object and then varArray.add(Jobject) and I keep getting issues with the ESP8266 rebooting and the stack is like this:
3fff0864: 00000014 00000014 40206ddc 3ffef0c0
3fff0874: 00000000 3ffef0c0 4020b469 3ffe89e8
3fff0884: 3fff0890 00000190 00000008 3fff0880
3fff0894: 00000000 736a2e69 00006e6f 3ffedd5c
3fff08a4: 00000000 4021eaa8 00000000 3ffefa84
3fff08b4: 00000013 00000013 4010020c 3ffe84c0
3fff08c4: 3ffef0c0 3fff0920 4010068c 00000031
3fff08d4: 0000000a 3fff2fec 4020f95c 3ffe84c0
3fff08e4: 3ffef0c0 3fff2fec 40206953 3ffefa84
3fff08f4: 00000012 00000012 3ffefa84 00000010
3fff0904: 3fff3034 00000000 4010053d 00000008
3fff0914: 00000000 00000020 40101c72 3ffe98e8
3fff0924: 4010191d 00000002 40101c72 3ffeda60
3fff0934: 40101806 00000001 00000000 00000000
3fff0944: 401015d3 00000000 3ffeda30 00000005
3fff0954: 00000000 00000020 40101c72 3ffe98e5
3fff0964: 40104f4f 3ffed370 3ffefa84 00000010
3fff0974: 3fff0a4c 00000000 4010053d 00000010
3fff0984: 3fff0a40 00000000 4010053d 3ffea184
3fff0994: 00000000 00000000 3fff3520 00000010
3fff09a4: 3fff0a4c 3fff0a4c 4020f24c 3ffe9518
3fff09b4: 00000000 3fff0a4c 4020f531 3ffe9518
3fff09c4: 00000000 3fff0a4c 00000001 00000001
3fff09d4: 3fff0a4c 3fff0a40 4020f5b4 3ffe0033
3fff09e4: 3fff0a90 3fff0a40 4020f445 3fff31f1
3fff09f4: 3ffe9608 3fff0a40 4020da7b 3ffefa84
3fff0a04: 00000451 00000451 4010020c 00000007
3fff0a14: 3fff0a90 3fff0a40 4010068c 00000000
3fff0a24: 00000000 00000000 4020f1f0 00000007
3fff0a34: 3fff0a90 3ffef0c0 3ffefa84 00000020
3fff0a44: 3fff0ad0 00000000 4010053d 3ffefa84
3fff0a54: 000003f5 000003f5 3ffefa84 00000020
3fff0a64: 3fff0af0 00000000 4020d53c 00000020
3fff0a74: 3fff0ad0 3fff0ad0 4020f24c 00000001
3fff0a84: 00000000 3fff0890 4020f29b 3ffefa84
3fff0a94: 000003d4 000003d4 4020d53c 00000001
3fff0aa4: 00000001 3fff25e4 4020b910 00000000
3fff0ab4: 3fffdad0 3fff25e4 4020d532 3fff25e4
3fff0ac4: 3ffef100 3fff25e4 4020d56e 00000000
3fff0ad4: 00000000 00000000 4020f3fc 3fff25e4
3fff0ae4: 3ffef100 3ffef0c0 4020d601 3fff31bc
3fff0af4: 0000001f 00000013 4020c588 3ffef100
3fff0b04: feefeffe 3ffefb70 00000001 00000001
3fff0b14: 4020cb44 0000000f 3ffefb70 00000000
3fff0b24: 00000000 3ffef0c0 3ffefb64 00000001
3fff0b34: 3ffef0e4 3ffef0c0 4020d7e3 3ffe8a30
3fff0b44: 00000000 000003e8 feefeffe 00000000
3fff0b54: 3fff3234 feefeffe feefeffe 3fffdad0
3fff0b64: 00000000 3ffefb5c 40206b98 3fffdad0
3fff0b74: 00000000 3ffefb5c 4020fa70 feefeffe
3fff0b84: feefeffe 3ffefb70 40100718 feefeffe
with exceptions (2) and (9) (if I try the first method or the second one) is it memory issue?
I have been optimising the code so there's only the Jobject root only one time opened and from there I access the subObjects and Arrays of Devices and Variables like this: root["Device"][number_of_device]["Vars"][variable]...
The text was updated successfully, but these errors were encountered: