Placing strings in flash
-
Hi.
This line in a sketch:
sendSketchInfo("Nod 200 - Altan", "V1.3");
places the string both in flash and in ram. And when doing this:
sendSketchInfo(PSTR("Nod 200 - Altan"), "V1.3");
Places the string only in flash but it don't seem to work.
the line:
#include <avr/pgmspace.h>
is in the begining of the sketch.
Would like to save the ramspace
Any ideas?
-
@kk02067 why do you get the impression that it doesn't work?
Does the code not compile? If so, are there any error messages?
Does the compile, but execution fails? If so, how does it fail?
-
@mfalkvidd
The string in the gateway becomes unreadable.
-
@kk02067 unreadable in what way? You're not giving us much to go on here
-
@kk02067 said:
PSTR
You cannot just replace any "string" in a sketch with a PSTR macro. As these strings are stored in a 'different' memory space (due to the AVR Harvard architecture) you also need other methods to handle these strings. As far as I know these are not implemented in MySensors.
A few ways to save RAM space:
- (simple) if you are using the same text at multiple places. Store the text once in a char array and point to and combine the unique parts
- (more complex) handle the copy from the ROM to RAM space yourself in a separate routine with a
pgm_read_byte(str)
function. Just search one of the arduino forums.
-
@AWI thanks for clarifying. I will read up on the subject. Strings i C is not my favourite subject.
Suggested Topics
-
Day 1 - Status report
Announcements ⢠23 Mar 2014, 22:45 ⢠hek 24 Mar 2014, 20:12 -
Echo request is not set
Troubleshooting ⢠12 Aug 2024, 15:36 ⢠kamilb85 3 Sept 2024, 08:58 -
Getting system time from the controller
Troubleshooting ⢠27 Feb 2025, 01:39 ⢠dpcons 3 Mar 2025, 01:00 -
DHT22 wrong sensor type in Home Assistant
Troubleshooting ⢠9 days ago ⢠Commodoreuno 3 days ago -
Compiling Sensor code using BME280 and ESP8266
Troubleshooting ⢠26 Feb 2025, 00:32 ⢠dpcons 26 Feb 2025, 06:22 -
Can not compile MySensors on esp8266
Troubleshooting ⢠24 Aug 2024, 15:35 ⢠TheoL 29 Aug 2024, 20:47