kpn-iot / thingsml-c-library

C library for ThingsML on your device
https://kpn-iot.github.io/thingsml-c-library/
MIT License
6 stars 4 forks source link

Issue with Arduino SAMD chips and serializing to json #7

Closed imle closed 2 years ago

imle commented 4 years ago

senml_helpers.cpp seems to be checking if ARDUINO is defined to do a bit of work with PROGMEM. This does not seem to be required or work with SAMD chips. This crashes the program for some of the SAMD based architectures.

imle commented 4 years ago

Specifically the place I am having issues with is in int printUnit(SenMLUnit unit), a resolution I have tested that works (for the Arduino Zero) is to change the check for #ifdef ARDUINO to #if defined(ARDUINO) && !defined(ARDUINO_ARCH_SAMD), however I think the code should be able to work as written, I am just not sure how to resolve it.

josephverburg commented 3 years ago

Using the Arduino MKR WAN 1300 (also SAMD processor) it works fine, the intention of the PROGMEM optimization is to reduce RAM usage on lower memory boards like the uno. The optimization can be restricted to only those boards, however i haven't looked into a defined(x) that would only use the optimization for those boards.

josephverburg commented 2 years ago

This optimization has been changed to only apply on specific processors, this fixes the incompatibility with SAMD processors since the optimization is not needed for SAMD boards since they include ample RAM. (since v1.3.0)