Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Placing strings in flash

Placing strings in flash

Scheduled Pinned Locked Moved Troubleshooting
6 Posts 3 Posters 1.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • kk02067K Offline
    kk02067K Offline
    kk02067
    wrote on last edited by
    #1

    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?

    mfalkviddM AWIA 2 Replies Last reply
    0
    • kk02067K kk02067

      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?

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @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?

      kk02067K 1 Reply Last reply
      0
      • mfalkviddM mfalkvidd

        @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?

        kk02067K Offline
        kk02067K Offline
        kk02067
        wrote on last edited by
        #3

        @mfalkvidd
        The string in the gateway becomes unreadable.

        mfalkviddM 1 Reply Last reply
        0
        • kk02067K kk02067

          @mfalkvidd
          The string in the gateway becomes unreadable.

          mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          @kk02067 unreadable in what way? You're not giving us much to go on here :)

          1 Reply Last reply
          0
          • kk02067K kk02067

            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?

            AWIA Offline
            AWIA Offline
            AWI
            Hero Member
            wrote on last edited by
            #5

            @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.
            kk02067K 1 Reply Last reply
            3
            • AWIA AWI

              @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.
              kk02067K Offline
              kk02067K Offline
              kk02067
              wrote on last edited by
              #6

              @AWI thanks for clarifying. I will read up on the subject. Strings i C is not my favourite subject.

              1 Reply Last reply
              1
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              20

              Online

              11.7k

              Users

              11.2k

              Topics

              113.1k

              Posts


              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • MySensors
              • OpenHardware.io
              • Categories
              • Recent
              • Tags
              • Popular