I am thinking about effectively simulating the PROGMEM helper class F("Hello") in my arduino simulator running on PC. One way I come up with was:
#define F(A) A
But it is not working. I'm making segment violation. I think on PC the "Hello" got stored with code but not data segment and my code attempts to write on it. Is there any other way to do this so that it will work?
Here is my fix, working but not elegantly by my standard 
char temp_buffer[256];
#define F(A) (strcpy(temp_buffer,A))
I don't know about this simulator but maybe it would be good for checking simple things.
I am intrigued about
I think on PC the "Hello" got stored with code but not data segment and my code attempts to write on it.
Surely that doesn't mean you would code to change a value stored in PROGMEM so I'm missing something.
liudr:
I'm making segment violation. I think on PC the "Hello" got stored with code but not data segment and my code attempts to write on it.
Er, that's not going to work on the Arduino anyway, because you can't write to Flash. Maybe that's a feature?
Right Nick. I was totally stuck on how to get this to work but forgot I was dealing with PROGMEM. I'll simulate with #define F(A) A so if any code in the simulator is trying to write to the string it would throw this exception.
GoForSmoke, here is the thread about simulator.
http://arduino.cc/forum/index.php/topic,96197.0.html
I essentially developed classes such as LiquidCrystal, DS1307 (one version of so many), phi_prompt, and lots of internal functions such as millis(), PROGMEM stuff to work on PC by creating these phony classes that use PC resources to print on console screen instead of LCD, system clock instead of RTC, and system clock to do millis etc. It works great! I can run my menus in this environment, faster to compile and run and I can use debugger. I'll get more non-hardware related functions to work so this simulator can be more widely used to develop and test programs. Now I just develop a program on PC and once I'm 100% happy, get the code back to arduino and load to a MEGA and it works with no problem.
There's so much about it, I need time to absorb. Not a simulator, an emulator, and there's a difference....
These kind of things might get some people started before they even have a board. Ahhh, the slippery road to geekdom!
GoForSmoke:
There's so much about it, I need time to absorb. Not a simulator, an emulator, and there's a difference....
These kind of things might get some people started before they even have a board. Ahhh, the slippery road to geekdom!
Thanks for suggestion of word. What I have made is indeed only emulating outcomes but not simulating any internal atmega chip operations. I have my board just can't stand spending one whole day debugging with next to no debug tools. With the emulator I can debug trace and peek at memory.
For things like F() I wouldn't mess with things at that level.
I would drop down to fix it with redefinitions of PROGMEM, PSTR, and all the
prog_read_xxx() routines.
(PSTR gets fixed by re-defining PROGMEM to nothing)
Most of it is pretty obvious, but
you may want to take a look at what was done for the Arduino port to the pic32.
They also had to undue much of the AVR proprietary extension for the harvard architecture
by re-defining much of the PROGMEM stuff into NOPs and casts.
(Get the mpide package and look in hardware/pic32/cores/pic32/wiring.h)
---- bill
bperrybap:
For things like F() I wouldn't mess with things at that level.
I would drop down to fix it with redefinitions of PROGMEM, PSTR, and all the
prog_read_xxx() routines.
(PSTR gets fixed by re-defining PROGMEM to nothing)
Most of it is pretty obvious, but
you may want to take a look at what was done for the Arduino port to the pic32.
They also had to undue much of the AVR proprietary extension for the harvard architecture
by re-defining much of the PROGMEM stuff into NOPs and casts.
(Get the mpide package and look in hardware/pic32/cores/pic32/wiring.h)
---- bill
Thanks Bill. I'll take a look. My primary purpose is to only emulate things that don't involve much hardware such as sensors and motors so I can build my menu system outside of arduino and put it back in after done. At the moment I have made some defs that redirects all PROGMEM to regular PC memory 