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. General Discussion
  3. loadState in 2.3.2 is not a happy function....

loadState in 2.3.2 is not a happy function....

Scheduled Pinned Locked Moved General Discussion
6 Posts 2 Posters 83 Views 2 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.
  • skywatchS Offline
    skywatchS Offline
    skywatch
    wrote on last edited by skywatch
    #1

    I am trying to get another node done and using saveState and loadState in the node for power cut recovery.

    Although I can get saveState to work in the receive function (wasn't expecting that to complie I must admit), whenever I try to loadState in setup I get an error like this.....

    Arduino: 1.8.9 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"

    WARNING: Spurious .ci folder in 'MySensors' library
    WARNING: Spurious .mystools folder in 'MySensors' library
    C:\Users\captain\Documents\Arduino\MYS-M_BED_LED-0.2\MYS-M_BED_LED-0.2.ino: In function 'void setup()':

    MYS-M_BED_LED-0.2:69:23: error: too many arguments to function 'uint8_t loadState(uint8_t)'

    loadState(10, lights);

                       ^
    

    In file included from C:\Users\captain\Documents\Arduino\libraries\MySensors/MySensors.h:433:0,

                 from C:\Users\captain\Documents\Arduino\MYS-M_BED_LED-0.2\MYS-M_BED_LED-0.2.ino:32:
    

    C:\Users\captain\Documents\Arduino\libraries\MySensors/core/MySensorsCore.cpp:550:9: note: declared here

    uint8_t loadState(const uint8_t pos)

         ^~~~~~~~~
    

    exit status 1
    too many arguments to function 'uint8_t loadState(uint8_t)'

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

    void setup()
    {
      Serial.begin(9600);
    
      // loadState(1, SOUND_Armed);
      // loadState(7, Auto_lights);
      loadState(10, lights);
      if (lights == 1) {
        newcodeRX == 1;
        code = 0xFFA25D;
      }
      irrecv.enableIRIn(); // Start the receiver
      LightMeter.begin();
      wdt_enable(WDTO_8S);
    }
    

    So I wonder why saveState(10, lights); compiles and loadState(10, lights); does not? What am I not knowing about this as I have not had this issue before.

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #2

      Do

      lights = loadState(10);
      
      skywatchS 1 Reply Last reply
      0
      • hekH hek

        Do

        lights = loadState(10);
        
        skywatchS Offline
        skywatchS Offline
        skywatch
        wrote on last edited by
        #3

        @hek You are a star!

        That works as expected - so I guess that saveState should also have this construction.

        Did this change recently or have I just been lucky doing it the way I originally had it?

        1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #4

          It has always been like this. In order to do like you propose, you'd have to send in a pointer for the light variable into the function to be able to update it. This would be a bit awkward and none standard for simple scalar values.

          skywatchS 1 Reply Last reply
          1
          • skywatchS Offline
            skywatchS Offline
            skywatch
            wrote on last edited by
            #5

            Just tested this and my assumption was incorrect it seems (using arduino 1.8.9 and mysensors 2.3.2).....

            Correct usage is......

            lights = loadState(10); //to read value from eeprom to variable.
            saveState(10, lights); //to write value from variable to eeprom.

            Now I got it!

            1 Reply Last reply
            0
            • hekH hek

              It has always been like this. In order to do like you propose, you'd have to send in a pointer for the light variable into the function to be able to update it. This would be a bit awkward and none standard for simple scalar values.

              skywatchS Offline
              skywatchS Offline
              skywatch
              wrote on last edited by
              #6

              @hek Thanks! Our posts crossed in the matrix!

              I even got this right on a previous sketch, but a lot has been going on for me lately and I am finding it difficult to concentrate on things.

              1 Reply Last reply
              0
              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