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

      Has this been done yet???

      Eliminate the need to connect via USB

      Instead of needing to connect to the Duet 2 Wifi via USB, the Duet 2 Wifi can first attempt to connect to a network.. but if the parameters don't exist, or have changed, and the connection fails it can then send its own wifi signal.

      If it sends its own wifi signal you can then connect to the Duet via your cellphone/computer and modify the network settings & reboot.

      RRF 3.01 introduced "GCode Meta Commands" (https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands) or if, elif, else, loops, etc.

      If something like this works I think it would help a ton of people! I'm thinking it will exist in either the top of config.g or as a macro, called toward the top of config.g

      What do you guys think? Ideas? opinions? is it impossible? why?

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

        i think you can do (or something close to that).

        if network.interfaces[0].actualIP = "0.0.0.0"
          M552 S-1
          M552 S2
        

        might want to add some M291, G4 or while state.upTime < to give wifi some time to connect before reverting

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

          Wouldn't you need to define network.interfaces? or is this defined somewhere and I've missed it?

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

            it shoud be an existing array for any duet with at least one network interface.

            check out M409 to query the object model at run time.

            https://duet3d.dozuki.com/Wiki/Gcode#Section_M409_Query_object_model

            (edit: i think i recall reading somewhere that during execution of config.g M552 is defered until the end, so you may have to resort to using daemon.g)

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

              this is the macro I put together:

              ;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.inferfaces[0].actualIP = "0.0.0.0":
              M552 S0 ; set module to idle
              G4 S3 ; dwell 3 seconds
              M587 SEve Ppassword I192.168.0.133 ; define parameters for wifi signal
              G4 S1 ; dwell 1 second
              M552 S2 ; emit wifi signal

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

              but I get the error :
              Error: in file macro line 9 column 4: meta command: unknown value 'inferfaces^.actualIP'

              I'm thinking the "if" statement needs a parameter which is only true when the machine fails to connect to a wifi signal, but I'm not sure what this parameter would be

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

                maybe you need to test if network.interfaces is null or not as well. do some poking with M409 and look at how the object model changes before and after.

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

                  I do not know if this will work in RRF3 conditional code, but you could try doing

                  if network.interface[0].actualIP
                      ; don't do anything
                  else
                      ; do the thing you want to do if no IP is acquired
                  

                  In some (most?) languages, if a value is null (or nil) it evaluates as false.

                  I could be making no sense right now so ignore me if it seems appropriate.

                  *not actually a robot

                  1 Reply Last reply Reply Quote 1
                  • 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
                                            • First post
                                              Last post
                                            Unless otherwise noted, all forum content is licensed under CC-BY-SA