[solved]<avr/pgmspace.h>issues, "pgm_read_byte_far is not defined in this scope"

Hello,
I’m trying to store a large amount of data, and access it later, and keep having problems with the pgmspace.h library

here is some sample code I’m trying to get to work-

#include <avr/pgmspace.h>
#include <avr/io.h>

const PROGMEM prog_uint32_t values[464] = {0,0,0,0,0,0,0,0,1257748416,2229081720,1240970799,2245859341,2764547699,1044158077,145805968,1665077079,3543340382,3647850701,783502585,1027380462,1161462934,1734760853,3576895619,3681405940,3560117998,3631073085,1257748418,2212304103,112250734,1631521837,766724968,1044158079,3419021935,1631521837,1257748418,2229081722,1161462934,1734760853,3543340381,3427764041,3170838271,2900333579,1161462934,1734760853,1257748416,2245859343,2307288137,1751538471,3720504383,4146893830,2093295842,2923692692,3170838271,2900333579,3368689078,1648299456,2256955281,1768316091,3419021935,1631521837,1619258661,3681405943,1619258661,3681405943,2102920994,2977155184,223386377,3648407043,3368689077,1648299459,1257748418,2229081722,1619258662,3681405940,2153253851,2960377565,240163998,3598074184,4100743723,606269605,3419021935,1631521837,625947228,414840686,2256955281,1768316091,2256955282,1768316088,1257748418,2245859341,162583588,1648299459,3419021932,1631521838,609169610,465173540,2256955280,1768316090,1257748416,2212304101,0,0,145805968,1665077079,4007399933,2740290906,1240970797,2245859343,2714214840,1060935698,2076518223,2974025549,3419021935,1631521837,2307288139,1751538469,1257748416,2245859343,3368689078,1648299456,2307288136,1751538470,1161462933,1734760854,3543340382,3647850701,3576895616,3681405943,2256955280,1768316090,3419021932,1631521838,1257748418,2229081722,1619258661,3681405943,1338156279,2548695961,4083966100,589491990,3543340382,3427764042,0,0,0,0,0,0,145805971,1665077076,1258711737,1507021574,0,0,783502587,1027380460,3820868508,2993932807,145805968,1665077079,3368689076,1648299458,3368689077,1648299459,400462113,2119371906,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3440843972,1821392518,4083966100,589491990,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4024177552,2790623763,2256955281,1768316091,1257748418,2245859341,1257748416,2245859343,0,0,2714214842,1060935696,3368689078,1648299456,0,0};
uint32_t iValuePrev;
uint32_t iValueCurr;
int i = 0;

void setup() {
  Serial.begin(9600);
  delay(500);
  Serial.println("working");
}

void loop() {

  iValuePrev = pgm_read_byte((values[i]));
  iValueCurr = pgm_read_byte(&(values[i]));
  Serial.println(iValuePrev);
  Serial.println(iValueCurr);
  delay(500);
  i++;
}

but it resutlts in

working
12
0
12
0
12
0
176
0
more seemingly random values between 0 and 255

and trying the same code with “pgm_read_byte_long” results in

sketch_oct07b.ino: In function ‘void loop()’:
sketch_oct07b:18: error: ‘pgm_read_byte_long’ was not declared in this scope

can anyone help me?

If you’re curious, here’s the project code it came from-

#include <IRremote.h>
#include <avr/pgmspace.h>

//#define pgm_read_byte_far(address_long)

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

PROGMEM prog_uint32_t values[464] = {0,0,0,0,0,0,0,0,1257748416,2229081720,1240970799,2245859341,2764547699,1044158077,145805968,1665077079,3543340382,3647850701,783502585,1027380462,1161462934,1734760853,3576895619,3681405940,3560117998,3631073085,1257748418,2212304103,112250734,1631521837,766724968,1044158079,3419021935,1631521837,1257748418,2229081722,1161462934,1734760853,3543340381,3427764041,3170838271,2900333579,1161462934,1734760853,1257748416,2245859343,2307288137,1751538471,3720504383,4146893830,2093295842,2923692692,3170838271,2900333579,3368689078,1648299456,2256955281,1768316091,3419021935,1631521837,1619258661,3681405943,1619258661,3681405943,2102920994,2977155184,223386377,3648407043,3368689077,1648299459,1257748418,2229081722,1619258662,3681405940,2153253851,2960377565,240163998,3598074184,4100743723,606269605,3419021935,1631521837,625947228,414840686,2256955281,1768316091,2256955282,1768316088,1257748418,2245859341,162583588,1648299459,3419021932,1631521838,609169610,465173540,2256955280,1768316090,1257748416,2212304101,0,0,145805968,1665077079,4007399933,2740290906,1240970797,2245859343,2714214840,1060935698,2076518223,2974025549,3419021935,1631521837,2307288139,1751538469,1257748416,2245859343,3368689078,1648299456,2307288136,1751538470,1161462933,1734760854,3543340382,3647850701,3576895616,3681405943,2256955280,1768316090,3419021932,1631521838,1257748418,2229081722,1619258661,3681405943,1338156279,2548695961,4083966100,589491990,3543340382,3427764042,0,0,0,0,0,0,145805971,1665077076,1258711737,1507021574,0,0,783502587,1027380460,3820868508,2993932807,145805968,1665077079,3368689076,1648299458,3368689077,1648299459,400462113,2119371906,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3440843972,1821392518,4083966100,589491990,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4024177552,2790623763,2256955281,1768316091,1257748418,2245859341,1257748416,2245859343,0,0,2714214842,1060935696,3368689078,1648299456,0,0};
uint32_t previous = 1;
uint32_t end_all = 4146893829;
int code = 0;

uint32_t output = 0;
uint8_t buf[8] = {0}; 	/* Keyboard report buffer */

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  delay(200);
  Serial.println("working");
}

void loop() {
  if (irrecv.decode(&results)) {
    if (results.value == end_all) {
      releaseAllKeys();
      previous = 1;
//    }else if(results.value == 656){
//      buf[2] = 127;
//      Serial.write(buf, 8);	// Send keypress
//    }else if(results.value == 1168){
//      buf[2] = 128;
//      Serial.write(buf, 8);	// Send keypress
//    }else if(results.value == 3216){
//      buf[2] = 129;
//      Serial.write(buf, 8);	// Send keypress
    }else{
      Serial.print("results.value = ");
      Serial.println(results.value);
      Serial.print("previous = ");
      Serial.println(previous);
      for (int i=0; i < 464; i=i+2) {
        //Serial.println(i);
        uint32_t iValuePrev = pgm_read_byte(&(values[i]));
        uint32_t iValueCurr = pgm_read_byte(&(values[i+1]));
        Serial.print("iValuePrev = ");
        Serial.println(iValuePrev);
        Serial.print("iValueCurr = ");
        Serial.println(iValueCurr);
        
        if (previous == iValuePrev){
          Serial.println("Previous Match");
          if(results.value == iValueCurr) {
            buf[2] = i/2;
            Serial.println("value detected");
            Serial.println(buf[2]);
            //Serial.println(i/2);
            //Serial.write(buf, 8);	// Send keypress
            i = 464;
          }
        }
      }
      //releaseKey();
      previous = results.value;
      Serial.print("new_previous = ");
      Serial.println(previous);
      
    }
    irrecv.resume(); // Receive the next value
  }
}

void releaseKey() {
  buf[0] = 0;
  buf[2] = 0;
  Serial.println("releaseKey");
  //Serial.write(buf, 8);	// Release key  
}

void releaseAllKeys() {
  buf[0] = 0;
  buf[1] = 0;
  buf[2] = 0;
  buf[3] = 0;
  buf[4] = 0;
  buf[5] = 0;
  buf[6] = 0;
  buf[7] = 0;
  Serial.println("releaseAllKeys");
  //Serial.write(buf, 8);	// Release key  
}

Hello and welcome,

You try to read a uint32_t with a function that returns a uint8_t (hence why the values are between 0 and 255)

Here are all the functions that you can use: http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html

Try pgm_read_dword

that fixed it, somehow I overlooked that, newbie mistake, thank you :)