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

    DSF Python bindings for DWC 3.4?

    Scheduled Pinned Locked Moved
    Duet Web Control
    6
    12
    799
    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.
    • peterwilliundefined
      peterwilli
      last edited by

      Hey there,

      Recently I've been playing around with DWC and DSF 3.4.0-rc1, but I couldn't get our Python plugins to work. I also saw the bindings were still made for 3.3: https://github.com/Duet3D/dsf-python

      Is this going to be updated soon? Anywhere I can help out? Thanks a lot!

      resamundefined 1 Reply Last reply Reply Quote 0
      • resamundefined
        resam @peterwilli
        last edited by

        @peterwilli do you get an error message, or what specifically is not working?

        All my plugins using the python bindings for 3.3 still work just fine with 3.4-rc1. I only had to bump the dependency in the plugin.json manifest.

        Here is some inspiration if you need a fully working sample:
        https://forum.duet3d.com/topic/24221/filament-spool-weight-measurements-plugin-and-hardware-design
        with a source code for a DSF/DWC plugin at https://github.com/Kriechi/duet-plugin-filament-load-cell/tree/main/plugin

        @mfs12 should know more if there is work required for full 3.4 compatibility.

        Nuramoriundefined mfs12undefined peterwilliundefined 4 Replies Last reply Reply Quote 1
        • Nuramoriundefined
          Nuramori @resam
          last edited by Nuramori

          @resam oooohhhhhhhhhh......

          Your example is almost a perfect base for a project I've been trying to do as a plug-in! Would you be willing to assist? It would be a very minor modification, basically allowing for TWO load cells to be polled, with the results being displayed.

          What I've built, but not quite coded into a final form, is a belt tension calibrator for an XY cube, that measures the force the belt applies to a loadcell (one per belt), to allow for equalizing the tension on both sides. It's fully built, and I have test code to validate the project, but I was looking for a way to make it a full plug-in. You project is essentially one half of what I was looking to do.

          1 Reply Last reply Reply Quote 0
          • mfs12undefined
            mfs12 @resam
            last edited by

            @resam said in DSF Python bindings for DWC 3.4?:

            @mfs12 should know more if there is work required for full 3.4 compatibility.

            I don't think so. As the connection concept didn't change and the object model is converted in a generic way to python. Eventually your plugin code breaks if there are changes in the object model.

            @dc42 But it would make sense to release an update for rrf-3.4.

            Visit me on github at https://github.com/mfs12/

            1 Reply Last reply Reply Quote 0
            • achrnundefined
              achrn
              last edited by

              As resam said, all I did to make my plugin work for 3.4 was to change the plugin.json lines to:

                  "dwcVersion": "3",
                  "sbcDsfVersion": "3",
              

              Previously both were set to 3.3.

              I couldn't work out a way to tell it ' > 3.3', or '3.3 || 3.4' and this definition is not quite right because the plugin mechanism only applies from 3.3 onwards (I think), but it works for me.

              1 Reply Last reply Reply Quote 0
              • peterwilliundefined
                peterwilli @resam
                last edited by peterwilli

                @resam Thanks, I made a sample plugin myself as and others have mentioned, bumped its version number. Here's the demo file I made and tried: https://github.com/Apyron/duet-plugin-workspace/tree/master/plugins/ExamplePythonPlugin

                Tomorrow I'll try the sample linked by you, so we can rule out if it's our setup or our plugin. Thanks a lot!

                Edit: The 3D printer guy is on vacation, so I can't check today.

                1 Reply Last reply Reply Quote 0
                • peterwilliundefined
                  peterwilli @resam
                  last edited by

                  Hello @resam.

                  We tried the example plugin as-is (i.e. no changes except the plugin.json). It looked like this:

                  {
                      "id": "FilamentLoadCell",
                      "name": "Filament Load Cell",
                      "author": "Thomas Kriechbaumer",
                      "version": "1.0.0",
                      "license": "MIT",
                      "homepage": "https://github.com/Kriechi/duet-plugin-filament-load-cell",
                      "dwcVersion": "3.4",
                      "sbcDsfVersion": "3.4",
                      "sbcRequired": true,
                      "sbcExecutable": "filament_load_cell.py",
                      "sbcExecutableArguments": null,
                      "sbcOutputRedirected":  false,
                      "sbcPermissions": ["registerHttpEndpoints"]
                  }
                  

                  The plugin loads partially, and the Python portion does not run. I get the following error:

                  Mar 07 10:07:11 raspberrypi DuetPluginService[1767]: [error] Plugin FilamentLoadCell: /usr/bin/env: ‘python3’: Permission denied
                  

                  I change the top line of filament_load_cell.py to #!/usr/bin/python3. This causes the script to run but throws the following error in journalctl:

                  Mar 07 10:25:06 raspberrypi DuetPluginService[1767]: [error] Plugin FilamentLoadCell: Traceback (most recent call last):
                  Mar 07 10:25:06 raspberrypi DuetPluginService[1767]: [error] Plugin FilamentLoadCell:   File "/opt/dsf/plugins/FilamentLoadCell/dsf/filament_load_cell.py", line 10, in <module>
                  Mar 07 10:25:06 raspberrypi DuetPluginService[1767]: [error] Plugin FilamentLoadCell:     from dsf.commands.basecommands import HttpEndpointType
                  Mar 07 10:25:06 raspberrypi DuetPluginService[1767]: [error] Plugin FilamentLoadCell:   File "/usr/local/lib/python3.7/dist-packages/dsf/__init__.py", line 10, in <module>
                  Mar 07 10:25:06 raspberrypi DuetPluginService[1767]: [error] Plugin FilamentLoadCell:     from . import commands, connections, http, initmessages, models
                  Mar 07 10:25:06 raspberrypi DuetPluginService[1767]: [error] Plugin FilamentLoadCell: ImportError: cannot import name 'commands' from 'dsf' (/usr/local/lib/python3.7/dist-packages/dsf/__init__.py)
                  Mar 07 10:25:06 raspberrypi DuetPluginService[1767]: [info] Plugin FilamentLoadCell: Process has been stopped with exit code 1
                  

                  I'm very much convinced now that something went wrong during upgrading of our Duet version on our Raspberry Pi.

                  resamundefined 1 Reply Last reply Reply Quote 0
                  • resamundefined
                    resam @peterwilli
                    last edited by

                    @peterwilli try running sudo pip3 install -U dsf-python to reinstall the latest dsf python package.

                    Also make sure you are on the latest DSF/RRF 3.4-rc2.

                    I haven't tested it yet on 3.4 -- there might be more permissions required. Try adding GpioAccess to the sbcPermissions in plugin.json.

                    @chrishamm whats the correct permission here? https://github.com/Duet3D/DuetSoftwareFramework/wiki/Third-Party-Plugins probably needs an update for 3.4?

                    chrishammundefined 1 Reply Last reply Reply Quote 0
                    • chrishammundefined
                      chrishamm administrators @resam
                      last edited by

                      @resam If you get an error message about python3 or env, the plugin must be reinstalled on 3.4-rc2 (or newer). Regarding FilamentLoadCell, see my post here and the updated plugin ZIP file I linked to.

                      I just added the two new permissions that were still missing (GpioAccess, WebcamAccess) to the docs, thanks for mentioning this.

                      Duet software engineer

                      resamundefined 1 Reply Last reply Reply Quote 0
                      • peterwilliundefined
                        peterwilli
                        last edited by

                        Hey everyone, thanks a lot for your help. We did as @resam told and upgraded to DSF/RRF 3.4-rc2. This fixed the problem, and we did not need to run sudo pip3 install -U dsf-python.

                        We also did the change that @achrn provided and set "dwcVersion" and "sbcDsfVersion" simply to "3". Now all of our plugins are working on 3.4 and we are grateful!

                        1 Reply Last reply Reply Quote 1
                        • resamundefined
                          resam @chrishamm
                          last edited by

                          @chrishamm are the permission names now compared case-insensitive? The Wiki page (still) lists them with a first capital letter, yet the plugin.json uses lower camel case.

                          chrishammundefined 1 Reply Last reply Reply Quote 0
                          • chrishammundefined
                            chrishamm administrators @resam
                            last edited by

                            @resam DSF doesn't care if it's upper-case or lower-case but I think DWC does. Hence I just updated the Wiki page - thanks for mentioning that.

                            Duet software engineer

                            1 Reply Last reply Reply Quote 1
                            • infiniteloopundefined infiniteloop referenced this topic
                            • First post
                              Last post
                            Unless otherwise noted, all forum content is licensed under CC-BY-SA