Giter Club home page Giter Club logo

Comments (8)

shatruddha avatar shatruddha commented on August 15, 2024

Is there an alternative to using stdlib?

from arduinojson.

bblanchon avatar bblanchon commented on August 15, 2024

Yes, actually strtod is not used when compiling with Arduino.

Look at Print.h and Print.cpp.
They both contains a condition that makes them different for Arduino:

#ifndef ARDUINO

We have to change this condition so that the code for Arduino is also used for Energia.

To fix this, edit Print.hand Print.cppand replace ARDUINO by ENERGIA.
This should do the trick.

Please and tell me if it works so I can update the library. 👍

from arduinojson.

shatruddha avatar shatruddha commented on August 15, 2024

I dig a bit deeper, and msp430 stdlib doesn't have strtod function.
This method is used only once in your library. I commented that part out, so I will not be able to get float values, but otherwise rest of the code is working.

from arduinojson.

bblanchon avatar bblanchon commented on August 15, 2024

Did you see my answer?

from arduinojson.

shatruddha avatar shatruddha commented on August 15, 2024

Yeah, but right now I'm occupied with another issue. Following code snippet works fine

char json [] = "{"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}";
JsonParser<16> parser;
JsonObject root = parser.parse(json);

but when instead of char array, I make a char pointer
char *json = "{"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}";
it doesn't.
I've not looked at the library yet, but in most of the cases, there will be a pointer to data rather than data stored in an array.
May be you might like to give some input/patch

from arduinojson.

bblanchon avatar bblanchon commented on August 15, 2024

It can be a char*, but the memory must be writeable because the JSON parser will insert '\0' and remove escape sequences.

The problem with:

char *json = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";

is that the compiler gives you a pointer to a read-only area. It's really an issue with this construction, not with char*.

Please see http://stackoverflow.com/a/1704433/1164966

You won't have any issue if you give a char* pointing to a buffer you allocated.

PS: I found an old LaunchPad MSP430, I'll try Energia as soon as I can.

from arduinojson.

shatruddha avatar shatruddha commented on August 15, 2024

To your earlier post,
There doesn't exist this define. Apart from this define, everything else is working like a charm.
The pointer Issues which I was facing, got resolved by reading more about cc3100 and the structs it uses.
Thanks for the library.
Cheers Dude!!

from arduinojson.

bblanchon avatar bblanchon commented on August 15, 2024

I downloaded the latest version of Energia from nergia.nu.
I can now confirm that both ARDUINO and ENERGIA are defined.
The examples compiles fine without any modification.

from arduinojson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.