Hi,
I am working on a simple menu system which consists of an array of
struct containing command name, a pointer to a function and an
information string:
struct ctl
{
char cmdname[10];
void* func;
char cmdhelp[];
} menu[] PROGMEM = {
{"?", welcome, " help\n"},
{"dump", hexdump, " src [addr] Dump memory\n"},
{"ihex", ihexload, " Download hex file\n"},
};
This array is in program memory.
To access an element (e.g. cmdname in the second element) I need it's
address (as I can only use pgm_read_byte(addr) to access it).
so far I have not been able to extract the address of such an element using:
pgm_read_byte(&menu[1].cmdname[0]);
The zero'th element works OK (it is the name of the array), but
subsequent array indexes are incorrect (a number of bytes wrong).
The third element of the struct is not dimensioned and is set by the
length of the strings, is this preventing the compiler from calculating
the correct address?
Normally the access systems to such elements are over arrow or dot
methods, but Harvard architecture prevents this.
Would appreciate any thoughts.
Cheers,
Bob
--
The Sun is out, the sky is blue. It's time to drive the MR2.
_______________________________________________
AVR-chat mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-chat