Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Conditional Gcode: Test if key exists?

    Scheduled Pinned Locked Moved
    General Discussion
    2
    7
    307
    Loading More Posts
    • 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.
    • mwolterundefined
      mwolter
      last edited by

      I am attempting to make a filament load macro that detects the movement of a Duet magnetic filament monitor. Running into an issue as the "calibrated" key does not exist in the object model until a print is started.

      It does not exist before print starts...

      M409 K"sensors.filamentMonitors[0]"
      {"key":"sensors.filamentMonitors[0]","flags":"","result":{"configured":{"mmPerRev":25.80,"percentMax":150,"percentMin":50,"sampleDistance":6.0},"enabled":true,"type":"rotatingMagnet"}}
      

      But after it does...

      M409 K"sensors.filamentMonitors[0]"
      {"key":"sensors.filamentMonitors[0]","flags":"","result":{"calibrated":{"mmPerRev":27.17,"percentMax":106,"percentMin":85,"totalDistance":577.4},"configured":{"mmPerRev":25.80,"percentMax":150,"percentMin":50,"sampleDistance":6.0},"enabled":true,"type":"rotatingMagnet"}}
      

      Before the print starts the key returns null...

      M409 K"sensors.filamentMonitors[0].calibrated"
      {"key":"sensors.filamentMonitors[0].calibrated","flags":"","result":null}
      

      But if I make a macro to test for null...

      if sensors.filamentMonitors[0].calibrated = null
      	echo true
      else 
      	echo false
      

      This is returned to the console...

      M98 P"0:/macros/test"
      Error: in file macro line 1 column 49: M98: cannot convert operands to same type
      

      Should I not be comparing to null? Is there a different type?

      1 Reply Last reply Reply Quote 0
      • dc42undefined
        dc42 administrators
        last edited by

        Which firmware version are you running? My latest build gives this:

        10/03/2020, 18:46:58 	echo sensors.filamentMonitors[0].calibrated = null
        true
        

        Duet WiFi hardware designer and firmware engineer
        Please do not ask me for Duet support via PM or email, use the forum
        http://www.escher3d.com, https://miscsolutions.wordpress.com

        mwolterundefined 1 Reply Last reply Reply Quote 0
        • mwolterundefined
          mwolter @dc42
          last edited by mwolter

          @dc42

          FIRMWARE_NAME: RepRapFirmware for Duet 2 WiFi/Ethernet FIRMWARE_VERSION: 3.01-RC3 ELECTRONICS: Duet Ethernet 1.02 or later FIRMWARE_DATE: 2020-02-29b4
          
          
          dc42undefined 1 Reply Last reply Reply Quote 0
          • dc42undefined
            dc42 administrators @mwolter
            last edited by

            If that same echo command doesn't work for you, then I guess it's fixed in the internal build ready for 3.01-RC4.

            Duet WiFi hardware designer and firmware engineer
            Please do not ask me for Duet support via PM or email, use the forum
            http://www.escher3d.com, https://miscsolutions.wordpress.com

            mwolterundefined 1 Reply Last reply Reply Quote 0
            • mwolterundefined
              mwolter @dc42
              last edited by

              Confirmed does not work on RC3. Will postpone this project until RC4.

              3/10/2020, 2:08:10 PM	echo sensors.filamentMonitors[0].calibrated = null
              Error: cannot convert operands to same type
              
              1 Reply Last reply Reply Quote 0
              • dc42undefined
                dc42 administrators
                last edited by

                You can try the internal build at https://www.dropbox.com/sh/3azy1njy3ayjsbp/AACquxr2m00eV568RZg5QG5wa?dl=0 if you wish - at your own risk.

                Duet WiFi hardware designer and firmware engineer
                Please do not ask me for Duet support via PM or email, use the forum
                http://www.escher3d.com, https://miscsolutions.wordpress.com

                1 Reply Last reply Reply Quote 0
                • mwolterundefined
                  mwolter
                  last edited by

                  @mwolter said in Conditional Gcode: Test if key exists?:

                  echo sensors.filamentMonitors[0].calibrated = null

                  That works, thanks!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Unless otherwise noted, all forum content is licensed under CC-BY-SA