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

    if M552 S1 fails; send M552 S2? Is this possible with RRF3??

    Scheduled Pinned Locked Moved
    General Discussion
    4
    22
    903
    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.
    • Benundefined
      Ben
      last edited by

      I did some poking with M409, took me a little while to figure out, but I think you were completely right originally bearer with the "network.interfaces[0].actualIP". If the board fails to connect the actualIP does turn to 0.0.0.0

      Here's where I'm at now:

      ;Attempt to connect to wifi signal, if it fails, emit a wifi signal

      M552 S0 ; set wifi module to idle
      G4 S3 ; dwell 3 seconds
      M552 S1 ; connect to predefined network
      G4 S10 ; dwell 5 seconds

      if network.interfaces[0].actualIP = "0.0.0.0"
      M552 S-1 ; turn off wifi module
      G4 S3 ; dwell 3 seconds
      M552 S0 ; set module to idle
      G4 S3 ; dwell 3 seconds
      M589 S"Eve" P"password" I192.168.0.133 ; define parameters for access point (AP)
      G4 S1 ; dwell 1 second
      M552 S2 ; emit access point

      M586 P0 S1 ; enable HTTP
      M586 P1 S0 ; disable FTP
      M586 P2 S0

      I get an error seen below:
      Error: in file macro line 9 column 46: meta command: cannot convert operands to same type

      What does it mean by cannot convert operand to same type?

      I like your idea bot, I think that'd be a good "final" but right now I'm trying to get it working as a macro

      A Former User? 1 Reply Last reply Reply Quote 0
      • A Former User?
        A Former User @Ben
        last edited by

        @Ben said in if M552 S1 fails; send M552 S2? Is this possible with RRF3??:

        cannot convert operands to same type

        would help to run m409 on network.interfaces[0].actualIP and/or network.interfaces to see what the status is as the error must be in relation to the type of network.interfaces[0].actualIP not matching the type of string "0.0.0.0" we're trying to compare it to

        1 Reply Last reply Reply Quote 1
        • Benundefined
          Ben
          last edited by

          @bearer is this what you mean?

          M409 K"network.interfaces[0].actualIP"
          {"key":"network.interfaces[0].actualIP","flags":"","result":"192.168.0.133"}<LF>ok<LF>

          M552 S-1
          WiFi module stopped<LF>ok<LF>

          M558 S0
          ok<LF>

          M588 S"*"
          ok<LF>

          (unplugged the machine, replugged it in)

          M409 K"network.interfaces[0].actualIP"
          {"key":"network.interfaces[0].actualIP","flags":"","result":"0.0.0.0"}<LF>ok<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported error: no known networks found<LF>WiFi module is idle<LF>WiFi reported err[Warning: Maximal number of bytes per line exceeded! Check the EOL (end-of-line) settings or increase the limit in the advanced terminal settings.]

          1 Reply Last reply Reply Quote 0
          • A Former User?
            A Former User
            last edited by

            sorry maybe i was unclear I meant to insert m409 on the line above the if statement so we get to see exactly what the value is immediately before the error is. but it looks to be a string to me, but I can't say I've played much with the object model so maybe someone else has a better idea.

            1 Reply Last reply Reply Quote 2
            • Benundefined
              Ben
              last edited by

              ah, my bad I see what you mean. I inserted the M409 command in as so:

              G4 S10 ; dwell 5 seconds

              M409 K"network.interfaces[0].actualIP"

              if network.interfaces[0].actualIP = "0.0.0.0"
              M552 S-1 ; turn off wifi module

              and got the feedback:

              7/11/2020, 2:17:46 PM {"key":"network.interfaces[0].actualIP","flags":"","result":"192.168.0.133"}Error: in file macro line 11 column 46: meta command: cannot convert operands to same type

              I appreciate your help @bearer !

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

                I think I see the problem. The value network.interfaces[0].actualIP has type IPAddress, whereas "192.168.0.133" has type String. So the two cannot be compared directly.

                However, if you apply the string concatenation operator to an IPAddress, it will convert it to type String. So you can use this instead:

                if (network.interfaces[0].actualIP^"Q") = "0.0.0.0Q"

                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

                A Former User? Benundefined 2 Replies Last reply Reply Quote 0
                • A Former User?
                  A Former User @dc42
                  last edited by

                  @dc42 said in if M552 S1 fails; send M552 S2? Is this possible with RRF3??:

                  has type IPAddress

                  how can we tell?

                  (and I presume 3.2 will result in an update of https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands#Section_Types if there any other interesting developments)

                  dc42undefined 1 Reply Last reply Reply Quote 0
                  • dc42undefined
                    dc42 administrators @A Former User
                    last edited by

                    @bearer said in if M552 S1 fails; send M552 S2? Is this possible with RRF3??:

                    how can we tell?

                    The Object Model Browser plugin for DWC 3.2 will display the types as well as the values.

                    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

                    A Former User? 1 Reply Last reply Reply Quote 1
                    • A Former User?
                      A Former User @dc42
                      last edited by

                      @dc42 said in if M552 S1 fails; send M552 S2? Is this possible with RRF3??:

                      Browser plugin

                      understatement: ❤

                      1 Reply Last reply Reply Quote 1
                      • Benundefined
                        Ben @dc42
                        last edited by

                        @dc42 said in if M552 S1 fails; send M552 S2? Is this possible with RRF3??:

                        if (network.interfaces[0].actualIP^"Q") = "0.0.0.0Q"

                        Hey this worked!!! I appreciate you!

                        I changed the parameters of the if statement from actualIP to changingMode:

                        So I'm now using:
                        if (network.interfaces[0].state^"Q") = "changingModeQ"

                        emit predefined access point

                        I found that while duet is in M552 S1 mode and can't find a wifi signal, it's actually in "changing mode" As of right now I like this parameter over assuming the IP, as sometimes the IP wouldn't be "0.0.0.0"

                        Thank you @dc42 @bearer and @bot

                        botundefined 1 Reply Last reply Reply Quote 1
                        • botundefined
                          bot @Ben
                          last edited by

                          Glad you have it working!

                          Though, is network.interfaces[0].state not a string type? If it's a string, the concatenation is likely unneeded.

                          *not actually a robot

                          1 Reply Last reply Reply Quote 0
                          • Benundefined
                            Ben
                            last edited by

                            @bot yes you are right. The macro works without converting it to a string.

                            1 Reply Last reply Reply Quote 0
                            • Benundefined
                              Ben @A Former User
                              last edited by

                              @bearer You were right about the daemon.g ... I tried to call the macro from the config.g, or just run it straight from the config.g but neither worked, I think you're right that M552 is delayed.

                              I couldn't find a lot of documentation on daemon.g out there, but I made the daemon.g file in the /sys folder and called the macro "WIFICONNECT" from it. From my understanding the daemon.g file is running constantly in the background? Will this harm anything in the long run? Right now I suspect if there is a temporary "lag" or disconnect with the wifi it will automatically emit it's own wifi signal.. which would inconvenient.

                              Here's my daemon.g:
                              G4 S30

                              M98 P"WIFICONNECT"

                              Here's what I have working for the WIFICONNECT macro:
                              ;Attempt to connect to wifi signal, if it fails, emit a wifi signal
                              G60

                              if (network.interfaces[0].state) = "changingMode" ; if unable to find/connect to network, emit network access point
                              M552 S-1 ; turn off wifi module
                              G4 S3 ; dwell 3 seconds
                              M552 S0 ; turn wifi module to idle
                              G4 S3 ; dwell 3 seconds
                              M552 S2 ; emit predefined access point
                              M586 P0 S1 ; enable HTTP
                              M586 P1 S0 ; disable FTP
                              M586 P2 S0 ; disable Telnet

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

                                @Ben, I suggest that in your script after you find that the state is "changingMode", you delay several seconds, then check it is still 'changing mode" before switching to access point mode.

                                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
                                • A Former User?
                                  A Former User
                                  last edited by

                                  you could make it run only once or twice by using

                                  if state.upTime < 10
                                    M98 P"WIFICONNECT"
                                  

                                  in (untested) theory it will only run the macro in the first 10 seconds after powering on the board. include a G4 and you can guarantee its only ran once.

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