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

    pydsfapi [v3.2.0] - Official Python Client Library for DSF

    Scheduled Pinned Locked Moved
    DSF Development
    6
    51
    3.1k
    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.
    • gtj0undefined
      gtj0
      last edited by

      Great!! I'll start looking at it this afternoon from both a functional and Python perspective.

      1 Reply Last reply Reply Quote 1
      • Danalundefined
        Danal
        last edited by Danal

        Fantastic! This was somewhere "on my list" and I'd much rather use an existing.

        Great community here...

        May I request a couple of usage examples in one of the readme.md files? I'd like to convert my tool alignment scripts ASAP.

        Delta / Kossel printer fanatic

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

          @Danal said in pydsfapi - Official Python Client Library for DSF [beta]:

          Fantastic! This was somewhere "on my list" and I'd much rather use an existing.

          Actually your existing library was a jump-start for me. 😄

          Great community here...

          So thanks to you as well!

          May I request a couple of usage examples in one of the readme.md files? I'd like to convert my tool alignment scripts ASAP.

          I will add some. EDIT: This might take until tomorrow. 😉

          EDIT2: Just so you don't have to starve until then

          # Initialize a new CommandConnection with debug mode enabled
          command_connection = connections.CommandConnection(debug=True)
          # Connect to default socket location
          command_connection.connect()
          
          try:
          	# Run a command
          	command_connection.perform_simple_code("M117 I'm alive", CodeChannel.SPI)
          finally:
          	# Close the connection
          	command_connection.close()
          

          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 0
          • gtj0undefined
            gtj0
            last edited by

            If @chrishamm doesn't show up soon, I think I'm just going to rewrite the entire DSF in python (or nodejs). 🙂

            Danalundefined wilrikerundefined 2 Replies Last reply Reply Quote 1
            • Danalundefined
              Danal @gtj0
              last edited by

              @gtj0 said in pydsfapi - Official Python Client Library for DSF [beta]:

              If @chrishamm doesn't show up soon, I think I'm just going to rewrite the entire DSF in python (or nodejs). 🙂

              I would actually vote for NodeJS, but either would be OK.

              Delta / Kossel printer fanatic

              1 Reply Last reply Reply Quote 1
              • Danalundefined
                Danal
                last edited by

                P.S. I did fix the M999 bug. Caveat Emptor and all that, this is my very first .net on Linux... etc, etc. If anyone is willing to try the 1.2.4.0 version of DuetControlServer with this fix, download this file:

                http://danalspub.com/wp-content/uploads/2020/03/DuetControlServer.zip

                Unzip, and place the two files inside in /opt/dsf/bin

                The 'DuetControlServer' file should have attributes of -rwxr-xr-x. If for some reason it does not, run chmod 755 DuetControlServer

                After the copies:
                sudo systemctl stop duetcontrolserver
                sudo systemctl start duetcontrolserver

                If you decide to go back, run:

                sudo apt-get reinstall duetcontrolserver

                or

                sudo apt-get reinstall duetcontrolserver=specific version number you wish

                You can find all available versions via:
                apt-cache policy duetcontrolserver

                Delta / Kossel printer fanatic

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

                  @gtj0 said in pydsfapi - Official Python Client Library for DSF [beta]:

                  If @chrishamm doesn't show up soon, I think I'm just going to rewrite the entire DSF in python (or nodejs). 🙂

                  He's currently working on both DWC and DSF to get the ObjectModel up to date.

                  But either way please don't replace one interpreted language for another. On a RPi use something that runs natively. Use Go or Rust. 😂

                  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

                  gtj0undefined 1 Reply Last reply Reply Quote 1
                  • gtj0undefined
                    gtj0 @wilriker
                    last edited by

                    @wilriker said in pydsfapi - Official Python Client Library for DSF [beta]:

                    @gtj0 said in pydsfapi - Official Python Client Library for DSF [beta]:

                    If @chrishamm doesn't show up soon, I think I'm just going to rewrite the entire DSF in python (or nodejs). 🙂

                    He's currently working on both DWC and DSF to get the ObjectModel up to date.

                    But either way please don't replace one interpreted language for another. On a RPi use something that runs natively. Use Go or Rust. 😂

                    HA!. I hear COBOL is making a comeback. 🙂 Actually the new "thing" is nim

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

                      @Danal (and interested others):

                      I have pushed a change that has added an examples.py that shows minimal examples of the three (four) most common usage scenarios.

                      Also mind that I renamed the main entry point from a generic connections.py to a more specific pydsfapi.py.

                      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

                      JBiscundefined 1 Reply Last reply Reply Quote 1
                      • Danalundefined
                        Danal
                        last edited by

                        Thank you! I will take a look, and target adapting this into my tool alignment scrips.

                        Delta / Kossel printer fanatic

                        1 Reply Last reply Reply Quote 1
                        • JBiscundefined
                          JBisc @wilriker
                          last edited by JBisc

                          @wilriker For beginners (of APIs) it would be very useful, so see an example in which you interact more with the duet (like move/ call M115 / read pin). I feel slighly overwhelmed with your example....

                          My Setup: Duet 3 MB6HC Main Board with attached RPI

                          wilrikerundefined 2 Replies Last reply Reply Quote 0
                          • wilrikerundefined
                            wilriker @JBisc
                            last edited by

                            @JBisc There is an update to pydsfapi coming in the next couple of days. I'll update the examples then also. Thanks for pointing it out.

                            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
                            • wilrikerundefined
                              wilriker @JBisc
                              last edited by

                              @JBisc I haven't changed much with the examples but added a lot of comments (see https://github.com/Duet3D/DSF-APIs/blob/dev/pydsfapi/examples.py). Is that already enough to get you started? If not can you please provide a detailed set of things you want to achieve and I'll be happy to either add this to the examples.py or reply to it here in the thread.

                              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

                              JBiscundefined 2 Replies Last reply Reply Quote 1
                              • JBiscundefined
                                JBisc @wilriker
                                last edited by JBisc

                                @wilriker Thanks. I will try it directly tomorrow and give feedback to you. Just for others who are searching: these changes are still on the dev Branch.

                                My Setup: Duet 3 MB6HC Main Board with attached RPI

                                1 Reply Last reply Reply Quote 0
                                • JBiscundefined
                                  JBisc @wilriker
                                  last edited by JBisc

                                  @wilriker Ok I tried. I took the latest commit on the dev branch (Hash: 7b7c9291aaa1e77bd570c2503f981a73410a0f32)

                                  I changed:

                                  cmd_conn.connect('/var/run/dsf/dcs.sock')
                                  

                                  I ran the example file with python 3.7 and the RPI and sudo rights (dcs.sock requires it)

                                  and I got the following error

                                  File "/home/shares/pi/HandwritingRoboter/src/DSF-APIs/pydsfapi/pydsfapi.py", line 234, in connect
                                    server_init_message.EXPECTED_SERVER_VERSION, server_init_message.version))
                                  AttributeError: 'ServerInitMessage' object has no attribute 'EXPECTED_SERVER_VERSION'
                                  

                                  Probably you have an Idea what that could be?

                                  My Setup: Duet 3 MB6HC Main Board with attached RPI

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

                                    @JBisc Yeah, the reason was me refactoring a name right before committing but after testing.

                                    But there is another problem why it would not have happened for me anyway: the version on the dev branch requires DSF 2.1.0 from unstable repo.

                                    EDIT: I pushed another change fixing this bug right before I posted here. So once you upgraded to DSF 2.1.0 the latest commit on dev should work.

                                    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 0
                                    • wilrikerundefined
                                      wilriker
                                      last edited by wilriker

                                      Release 2.1.0

                                      I present to you the first official release of pydsfapi which can be found at GitHub Releases page as usual.

                                      This is the first release of pydsfapi and it is target at compatibility with Duet Software Framework 2.1.0 and later (it specifically does not work with DSF 1.2.4 and earlier).

                                      With this release the package structure has been brought to a Python standard layout and a setup.py has been added for easier installation via disttools.

                                      What's missing

                                      • There are no concrete class implementations representing the ObjectModel. For now there is a placeholder class MachineModel that has all the values as dict with dicts inside it.

                                      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
                                      • wilrikerundefined
                                        wilriker
                                        last edited by

                                        Release v2.1.2

                                        This release can be found as usual on GitHub Releases page.

                                        Port changes from upstream

                                        • Increase PROTOCOL_VERSION to 6
                                        • Add G53 to string output of commands that use it

                                        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 2
                                        • wilrikerundefined
                                          wilriker
                                          last edited by

                                          Release 3.1.0

                                          This release syncs changes and version with latest DuetSoftwareFramework and can be found as usual on GitHub Releases page.

                                          Ported changed from upstream

                                          • Increase PROTOCOL_VERSION to 7
                                          • Add new Aux2 CodeChannel
                                          • Comments now use Q as CodeType (instead of C)
                                          • Letter for unprecedented parameters has been changed from empty string to @

                                          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 2
                                          • wilrikerundefined
                                            wilriker
                                            last edited by

                                            Release 3.1.1

                                            Minor release that just updates PROTOCOL_VERSION to 8 to be in line with DuetSoftwareFramework 3.1.1.

                                            Can be found at 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

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