DSF Python bindings for DWC 3.4?
-
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!
-
@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.
-
@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.
-
@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.
-
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.
-
@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.
-
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.
-
@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 inplugin.json
.@chrishamm whats the correct permission here? https://github.com/Duet3D/DuetSoftwareFramework/wiki/Third-Party-Plugins probably needs an update for 3.4?
-
@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.
-
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! -
@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. -
@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.
-