Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
stu_san
PostPosted: Apr 29, 2010 - 05:04 PM
Raving lunatic


Joined: Dec 30, 2005
Posts: 2327
Location: Fort Collins, CO USA

wek wrote:
Stu, and others, may I ask you to give it a try in the wild?
I hope to give it a shot sometime today. Kinda busy on a different (embedded Linux) project so I may not get to it today, but will definitely tomorrow.

Stu

_________________
Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!
 
 View user's profile Send private message  
Reply with quote Back to top
dalew1
PostPosted: May 24, 2010 - 06:41 AM
Rookie


Joined: Apr 22, 2008
Posts: 21


wek wrote:
Stu, and others, may I ask you to give it a try in the wild?
Jan

Excellent. Appears to behave correctly on a set of code I tried. Code is 25k LOCs on a MEGA2560 and lots of strings amounting to some 20kbytes. No problems observed.

This is one of those things that shouldn't need to be an explicit optimization, it should be a given where possible. There should be no reason to have to compute the length of a string in PROGMEM.

I did have to do some minor reorganization of the code.

Its stating the obvious, but if the strings are not visible in the current object module, the length can't be computed at compile-time. Solving this would be really neat!

With larger projects, there will always be multiple object modules and strings may be reused across them. As a result, I had all strings in one C module. Makes things simpler when it comes to supporting multiple languages. It takes a bit of careful thought to rearrange things, into a header-file, for example.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
wek
PostPosted: May 24, 2010 - 07:46 AM
Raving lunatic


Joined: Dec 16, 2005
Posts: 3198
Location: Bratislava, Slovakia

dalew1 wrote:
Appears to behave correctly on a set of code I tried.

Thanks for trying.

dalew1 wrote:
This is one of those things that shouldn't need to be an explicit optimization, it should be a given where possible. There should be no reason to have to compute the length of a string in PROGMEM.

While the string itself in FLASH won't change, the *pointer* used in this function may be a variable, pointing to various FLASH strings. In this case, the length "calculation" is inevitable. Also, part of the FLASH may be used as a permanent configuration memory, storing for example the language-dependent strings, being updated through some self-programming mechanism (bootloader), after compilation. Here, functions like strlen/strcmp etc. working on FLASH "variables" may make sense.

JW
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
stu_san
PostPosted: May 24, 2010 - 03:51 PM
Raving lunatic


Joined: Dec 30, 2005
Posts: 2327
Location: Fort Collins, CO USA

I forgot to report on this - my ATmega2560 app (> 90K LOC) is running perfectly with the mod. I have both cases handled by the macro. Total of 5 uses of strlen_P in the code, but they are exercised pretty often in normal usage.

Stu

_________________
Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!
 
 View user's profile Send private message  
Reply with quote Back to top
wek
PostPosted: May 24, 2010 - 06:39 PM
Raving lunatic


Joined: Dec 16, 2005
Posts: 3198
Location: Bratislava, Slovakia

Arigato gozaimasu, Stu-san.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
stu_san
PostPosted: May 25, 2010 - 03:32 PM
Raving lunatic


Joined: Dec 30, 2005
Posts: 2327
Location: Fort Collins, CO USA

Domo, domo. Very Happy

Stu

_________________
Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits