>From: iotivity-dev-bounces at lists.iotivity.org [mailto:iotivity-dev- >bounces at lists.iotivity.org] On Behalf Of Thiago Macieira >Sent: Friday, January 16, 2015 1:44 PM >To: iotivity-dev at lists.iotivity.org >Subject: [dev] Cross-platform coding for Arduino (e.g. PROGMEM) > >Has anyone done cross-platform coding for Arduino and could share some >best- pratices? > >I've just noticed that a great deal of our code has #ifdef ARDUINO just so >some functions or variables are declared with PROGMEM. > >For example (simplified, from oclogger.h): > >#ifndef ARDUINO >void OICLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, >uint16_t bufferSize); #else void OICLogBuffer(LogLevel level, PROGMEM >const char * tag, const uint8_t * buffer, uint16_t bufferSize); #endif > >The use of a macro seems to point to a coding practice of just #define'ing it >to >empty on other systems. Do other projects do that? Is that recommended? > >-- >Thiago Macieira - thiago.macieira (AT) intel.com > Software Architect - Intel Open Source Technology Center
Hi Thiago, On Arduino, if we do not classify the 'logging string' as PROGMEM, it will sit in the .data segment and will occupy space in SRAM. On ArduinoMega 2560, this becomes a problem as we have ONLY 8Kb of SRAM to play with and our stack (when debug mode enabled) cannot run successfully without forcing all the strings to Flash memory. Thanks Sachin
