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

    [DSF Extension] Exec On MCode (was: Shutdown SBC)

    Scheduled Pinned Locked Moved
    DSF Development
    22
    117
    10.0k
    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.
    • GoremanXundefined
      GoremanX
      last edited by

      Works perfect... now I just need to move the camera off-system. Apparently while the Duet is printing (in SBC mode), the SPI bus on the attached pi gets too busy to handle the HQ camera feed and all the captured photos get messed up 😞

      Phaedruxundefined 1 Reply Last reply Reply Quote 0
      • Phaedruxundefined
        Phaedrux Moderator @GoremanX
        last edited by

        @GoremanX said in [DSF Extension] Exec On MCode (was: Shutdown SBC):

        Apparently while the Duet is printing (in SBC mode), the SPI bus on the attached pi gets too busy to handle the HQ camera feed and all the captured photos get messed up

        Interesting. Pi cam module?

        Z-Bot CoreXY Build | Thingiverse Profile

        GoremanXundefined 1 Reply Last reply Reply Quote 0
        • GoremanXundefined
          GoremanX @Phaedrux
          last edited by

          @Phaedrux said in [DSF Extension] Exec On MCode (was: Shutdown SBC):

          Interesting. Pi cam module?

          Yeah it's a genuine Raspberry Pi HQ camera. It works fine as long as the Duet isn't printing, but as soon as it starts printing, the photos end up with very random wide magenta bands all the way across and weird lines of noise. At the end of the print everything returns to normal. So I was gonna build a separate camera using the same HQ module and a Pi Zero W

          Phaedruxundefined 1 Reply Last reply Reply Quote 0
          • Phaedruxundefined
            Phaedrux Moderator @GoremanX
            last edited by

            @GoremanX said in [DSF Extension] Exec On MCode (was: Shutdown SBC):

            a separate camera using the same HQ module and a Pi Zero W

            I do the same with MotionOS and it works quite well.

            Z-Bot CoreXY Build | Thingiverse Profile

            1 Reply Last reply Reply Quote 0
            • Greg_the_makerundefined
              Greg_the_maker
              last edited by

              Hello,

              I'm a complete idiot when it comes to programming and I am finding the instructions a little vague. I feel I need some assistance please 🙂

              The Installation is as follows.

              a3fd2a10-0826-4fe3-95d4-9a67debde466-image.png

              Download.

              Does this mean git clone? That's what I did anyway.

              Rename to just execonmcode

              Rename what? There are a load of .go files in the directory, do I rename one of those?

              chmod etc

              The rest of the install I can manage. I think.

              Thank you for your time.

              wilrikerundefined 1 Reply Last reply Reply Quote 0
              • PCRundefined
                PCR
                last edited by PCR

                look some pots up. I made a video about this @Greg_the_maker

                1 Reply Last reply Reply Quote 0
                • Greg_the_makerundefined
                  Greg_the_maker
                  last edited by

                  What is it i need to be looking for?

                  1 Reply Last reply Reply Quote 0
                  • PCRundefined
                    PCR @PCR
                    last edited by

                    @PCR said in [DSF Extension] Exec On MCode (was: Shutdown SBC):

                    made a little videos how to install it. Mainly for my own reference later

                    How to install and test

                    How to make it as a systemservice

                    Here you go

                    1 Reply Last reply Reply Quote 0
                    • Greg_the_makerundefined
                      Greg_the_maker
                      last edited by

                      thank you 🙂

                      1 Reply Last reply Reply Quote 0
                      • wilrikerundefined
                        wilriker @Greg_the_maker
                        last edited by

                        @Greg_the_maker Thanks for pointing that out. I will point the download instructions towards the GitHub Releases page. For there it should be clear what is meant by renaming also.

                        Manuel
                        Duet 3 6HC (v0.6) with RPi 4B on a custom Cartesian
                        with probably always latest firmware/DWC (incl. betas or self-compiled)
                        My Tool Collection

                        1 Reply Last reply Reply Quote 1
                        • Greg_the_makerundefined
                          Greg_the_maker
                          last edited by

                          Is tehre a way to get terminal messages displayed in the console?

                          For example I need to see a list of usb devices with lsusb, is it possible to have that list returned as an M117 message or similar?

                          wilrikerundefined 1 Reply Last reply Reply Quote 0
                          • wilrikerundefined
                            wilriker @Greg_the_maker
                            last edited by

                            @Greg_the_maker In theory this is possible. Right now successful execution will discard the application output and error in execution results in an error being sent to DCS what failed (e.g. file not found but still not the output of the application).

                            I could add that but I am not sure how it will deal with line-breaks.

                            Manuel
                            Duet 3 6HC (v0.6) with RPi 4B on a custom Cartesian
                            with probably always latest firmware/DWC (incl. betas or self-compiled)
                            My Tool Collection

                            Greg_the_makerundefined 1 Reply Last reply Reply Quote 0
                            • Greg_the_makerundefined
                              Greg_the_maker @wilriker
                              last edited by

                              @wilriker Ahh ok. was just a thought. would be a nice feature to have though 😉

                              wilrikerundefined 1 Reply Last reply Reply Quote 0
                              • wilrikerundefined
                                wilriker @Greg_the_maker
                                last edited by wilriker

                                @Greg_the_maker I have to correct myself. In case of an error it will indeed return the output of stdout and stderr combined as an error message. But since we are in short-lived world things can be changed quickly and thus:

                                Release v5.1.2

                                This release adds a new flag -returnOutput to be able to send the collected output of a successful run back to DCS. Prior this was only the case if the execution of the command failed.
                                Note that this cannot be combined with -execAsync.

                                Download

                                As usual get it from GitHub Releases page.

                                Manuel
                                Duet 3 6HC (v0.6) with RPi 4B on a custom Cartesian
                                with probably always latest firmware/DWC (incl. betas or self-compiled)
                                My Tool Collection

                                Greg_the_makerundefined oozeBotundefined 2 Replies Last reply Reply Quote 4
                                • Greg_the_makerundefined
                                  Greg_the_maker @wilriker
                                  last edited by

                                  @wilriker Fantastic! Works exactly as desired. Have my upvote!

                                  1 Reply Last reply Reply Quote 0
                                  • oozeBotundefined
                                    oozeBot @wilriker
                                    last edited by

                                    @wilriker Could you please provide a simple example of using the -returnOutput flag? Thanks

                                    wilrikerundefined 1 Reply Last reply Reply Quote 0
                                    • wilrikerundefined
                                      wilriker @oozeBot
                                      last edited by wilriker

                                      @oozeBot said in [DSF Extension] Exec On MCode (was: Shutdown SBC):

                                      @wilriker Could you please provide a simple example of using the -returnOutput flag? Thanks

                                      Simple example:

                                      execonmode -mCode 7777 -command "whoami" -returnOutput
                                      

                                      will not just confirm successful completion of the command but as part of this return the output of whoami (that returns the user execonmcode is started as, so probably root) so you can see it e.g. in DWC.

                                      Manuel
                                      Duet 3 6HC (v0.6) with RPi 4B on a custom Cartesian
                                      with probably always latest firmware/DWC (incl. betas or self-compiled)
                                      My Tool Collection

                                      oozeBotundefined 2 Replies Last reply Reply Quote 0
                                      • oozeBotundefined
                                        oozeBot @wilriker
                                        last edited by

                                        @wilriker Thanks. So the return is echo'ed in DWC, correct? Could the return value be evaluated within conditional gCode?

                                        garethkyundefined 1 Reply Last reply Reply Quote 0
                                        • garethkyundefined
                                          garethky @oozeBot
                                          last edited by garethky

                                          @oozeBot said in [DSF Extension] Exec On MCode (was: Shutdown SBC):

                                          @wilriker Thanks. So the return is echo'ed in DWC, correct? Could the return value be evaluated within conditional gCode?

                                          I was thinking about this today. Currently there are no variables so there is nothing to write the result back to. (there is a result int from the last code but it can't contain other data types) I think we might have to wait for variables and then we could write the value back to a global.

                                          When that happens... it should be possible to set up an MCode that stores and retrieves values from a file on the SD card. So we could do what M500 does but with key/value semantics of M409:

                                          M7500 K"some.key" V"The value"
                                          M7500 K"some.other.key" V0.05
                                          

                                          and then get them back in a global with:

                                          M7500 K"some.key"
                                          echo {global.M7500_value}    ; or whatever you want to name it!
                                          

                                          and stored on disk as JSON:

                                          "some": {
                                              "key": "The Value"
                                              "other": {
                                                  "key": 0.05
                                              }
                                          }
                                          
                                          1 Reply Last reply Reply Quote 1
                                          • EMRosaundefined
                                            EMRosa
                                            last edited by

                                            Great work! This is incredibly useful and appreciated!

                                            Is there a way to pass quotes through the -command argument?
                                            For example:

                                            execonmcode --command "sudo pkill -fx "blah, blah, blah"" -mCode 7720 -execAsync
                                            

                                            I've tried single quotes, escape characters, and changing it to an argument passed through the m-code command;

                                            execonmcode --command "sudo pkill -fx %F" -mCode 7720 -execAsync
                                            

                                            and then tried from DWC:

                                            M7720 F"python3 script.py"
                                            

                                            but the full argument gets lost. I foolishly tried double quotes and DSF crashed. haha.

                                            Please, forgive my inexperience. There is probably a simple answer to this, but it seems to escape my googling ability.

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