Hi all,
I'd like to retrieve a JSON string using HTTP on the YUN, and then parse it and be able to retrieve values. The length of the JSON string is around 400 characters. I've tried many things (using Process to call a Python script outputing it, and then get the string back in a char array, then parse it using Arduino JSon - here: GitHub - bblanchon/ArduinoJson: 📟 JSON library for Arduino and embedded C++. Simple and efficient.). When this is the only thing I'm doing in the sketch, it's working out and I get the values I want; however, if the sketch is more complex than that, it doesn't return me anything. I suspect a memory problem though, and I was wondering if you have any suggestions to get that working on such a long string.
I saw that Arduino Json (here: GitHub - interactive-matter/aJson: aJson is an Arduino library to enable JSON processing with Arduino. It easily enables you to decode, create, manipulate and encode JSON directly from and to data structures.) can handle streams, but I cannot get it working..
Thanks a lot.
Maybe you should handle it on the linux side and whatever desition/action communicate to arduino.
mart256:
Maybe you should handle it on the linux side and whatever desition/action communicate to arduino.
Agreed. Do as much as you can on the Linux side. Python is good at handling/decoding JSON data. Parse and process the data as much as you can in the Python code, and only send the final results to the sketch.
Hi,
Thanks for your answers. I've already thought of that, but how to send results to the sketch? I have a lot of variables (around 30) to send out, I tried through Bridgeclient() on the Python side and Bridge.get() on the Arduino side, it's not giving me good results.
I've also tried through Mailbox (after changing the max size in the Arduino core code), I've got the same problems than while using Process..
Any thoughts on how to transfer processed data?
Thanks
ludoca:
Any thoughts on how to transfer processed data?
It depends... what kind of data are we talking about, and what is the sketch going to do with it?
Remember that the USB host port, all of the networking hardware and code, and the SD card are all managed by the Linux processor. The only thing under direct control of the sketch is the micro-USB device port and the shield connectors. If the sketch is just going to send the data out over the network, or store it on the SD card, there is no point even sending it to the sketch. It really only makes sense to send the data to the sketch if you need it to control the shield I/O pins, or send out the micro-USB port.
I have some ideas, but which is best depends on the type and quantity of data, how often it is updated, and what triggers an update with new data.