Need help with arrays and PROGMEM data

I was trying to store some data of my program using PROGMEM. However when I want to take it back, I'm having some issues.

First what I tried and worked:

const PROGMEM char tepe[16] = "10728 H 28888";

char ttpp[16];

strcpy_P(ttpp, tepe);

That works ok and I can print back the information on an LCD

Now I have more information, so I made a struct of "Satellites" holding information for each satellite I need, something like this.

struct satelites {
  char nombre[16];
  float grados;
  float elevacion;
  float skew;
  char TP[16];

And then tried:

const PROGMEM satelites instelsat_21 = { "Intelsat 58.0W", 0.8, 49.8, -0.7, "11757 V 2400" };

const PROGMEM satelites listaSatelites[1] = {instelsat_21};

strcpy_P(ttpp, listaSatelites[0].TP);

When I do that method, it doesn't work.

However, if I do:

strcpy_P(ttpp, instelsat_21.TP);

So I'm guessing there is something wrong with the way I'm storing the array of my different satelites elements? (Even they do work when not using PROGMEM so not sure)

Any help would be appreciated.

PS: I show the example with 1 Satellite but I will have about 10 when done.

What do you suppose that strcpy_P() is actually doing? The second argument is a location in PROGMEM where there is a string to be copied. In your first example, that is what you are providing it.

In your second example, that is not what you are providing it.

You stored the pointer in PROGMEM saving 2 whole bytes of SRAM, but made your coding an order of magnitude more difficult.

First, you need to get the pointer out of PROGMEM. Then, you can use the SRAM pointer to access the data from PROGMEM.

But shouldn't... listaSatelites[0].TP and instelsat_21.TP be equivalents?

What you suggesting I do in this case? Something like...

satelites tempSat;
tempSat = listaSatelites[0];

and then

strcpy_P(ttpp, tempSat.TP);

This came up a couple of days ago. It was not really solved to my satisfaction but there are two ways of getting around it in this thread.

You can define the nested struct data inline or you can change the main struct so that it points to the address of the nested structs.

But shouldn't... listaSatelites[0].TP and instelsat_21.TP be equivalents?


instelsat_21 is a pointer in PROGMEM.
listaSatelites[0] is a pointer in PROGMEM to a pointer in PROGMEM.

Not the same things at all.