Giter Site home page Giter Site logo

Comments (3)

PaulStoffregen avatar PaulStoffregen commented on August 18, 2024

On Mega2560, the following sketch compiles OK:

It may compile, but it certainly doesn't work. It has 3 fatal flaws:

1: There's no Serial.begin(), so it can't print anything
2: It doesn't actually store any pointers for pgm_read_ptr() to read. The array has 5 chars (including terminating zero), not a pointer to chars.
3: The array is local scope (stack allocated), which doesn't work with PROGMEM.

Here is a correct program which actually works when run on Uno or Mega (yes, I did just test both of them).

const char * const str_debug_1[] PROGMEM = {"ECHO", "ECHO2"};

void setup() {
  Serial.begin(9600);
  Serial.println("test pgm_read_ptr:");
  Serial.println((char*)pgm_read_ptr(&str_debug_1[0]));
  Serial.println((char*)pgm_read_ptr(&str_debug_1[1]));
}

void loop() {
}

This doesn't solve the issue on Arduino Due, but at least a working test case might be helpful?

from arduinocore-sam.

bobc avatar bobc commented on August 18, 2024

There is no doubt that pgm_read_ptr works on AVR platforms, so it doesn't help at all, frankly. Creating a runnable test case for Due once the compile issue has been fixed is a trivial exercise.

Any thoughts on how to fix it?

from arduinocore-sam.

PaulStoffregen avatar PaulStoffregen commented on August 18, 2024

Use (*(void * const *)(addr))

arduino/ArduinoCore-samd@4ffc9d2

from arduinocore-sam.

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.