Skip to content

PROGMEM documentation issue #3430

Closed
Closed
@adam-palmer1

Description

@adam-palmer1

I believe that reading the char array from PROGMEM at url https://www.arduino.cc/en/Reference/PROGMEM is incorrect.

In the block of code;

 // read back a char
  for (k = 0; k < strlen(signMessage); k++)
  {
    myChar =  pgm_read_byte_near(signMessage + k);
    Serial.print(myChar);
  }

strlen can not be used on signMessage, but strlen_P should be used instead which works correctly. As a secondary and for efficiency, the string length need not be calculated on every iteration of the for loop but can be calculated outside;

  // read back a char
  int len = strlen_P(signMessage);
  for (k = 0; k < len; k++)
  {
    myChar =  pgm_read_byte_near(signMessage + k);
    Serial.print(myChar);
  }

Regards,

Adam Palmer
http://www.iodigitalsec.com/

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions