@chrishamm Thanks for the input. I've been doing some testing and thinking.
Unfortunately, when I try your package I get "Installation failed!" - "InternalServerException in InstallPlugin: Win32Exception in InstallPlugin: An error occurred trying to start process '/usr/bin/pip' with working directory '/'. No such file or directory"
I don't have pip installed (though I do have pip3), and both the 'weigh' helper script and the plugin python script are python3. I assume the package handling has decided to try and install python2 versions. One approach would be to let it (i.e. give it a python2 pip and let it get on with it), but that seems a little clumsy if I'm not using python2 versions. Does the plugin system's handling of python and pip distinguish v2 and v3? Does it just try and install both versions if any version is requested?
I notice you've also added a line "sbcPackageDependencies": ["libatlas-base-dev"], and I don't know what that is about - is that a part of the plugin handling internals?
With respect to location of the settings file, I must admit putting it in the system directory is attractive (and hadn't occurred to me), because then the user at the web interface can open it with ease and see what values are set. I have added a default one, but it just has some comments / instructions in it - I think values are too dependant on the vagaries of different load cells to have defaults pre-set. It only needs readSystem permissions (the plugin doesn't write to it, only the helper writes).
[As an aside, the page https://github.com/Duet3D/DuetSoftwareFramework/wiki/Third-Party-Plugins#list-of-permissions lists all the permission names as starting with an upper case letter. However, if I use permission "ReadSystem" I get an error "Invalid plugin manifest", it needs to be "readSystem".]
However, putting the file there needs some additional install steps, because the helper script (which is run from outside DSF) needs to read and write it.
New package
I've made an intermediate package somewhat between my previous and chrishamm's suggested changes. This doesn't use the pip functionality (for reasons as above) but does move the config file. I've also put the helper script into the zip file to slighly ease distribution.
Here it is (take the .txt off before trying to use it): WeighFilament.zip.txt
This has a slightly different install sequence compared to the post at the top of the thread:
Installation
You need some python libraries. At a command prompt: sudo apt install python3-rpi.gpio python3-numpy python3-setuptools (others too, but they are probably already installed).
You need to download and install the HX711 library from https://github.com/tatobari/hx711py This is pure python and relatively straightforward. It appears to be written for python2, but runs happily under python3 as well, so having downloaded and unpacked you cd into the repository folder and python3 setup.py install.
Enable the plugin service on the Pi. See https://forum.duet3d.com/post/219064 (but that says you won't need to do that soon). (Also, I don't think I put apparmor in my cmdline.txt, and it seems to work for me).
Drag and drop the plugin zip file onto the 'Install Plugin' button on the Plugins / External Plugins page of DWC, but don't start it.
At a command prompt: sudo chmod a+rw /opt/dsf/sd/sys/spoolweigh.txt This is so the helper script can write into the configuration file.
At a command prompt: sudo chmod a+x /opt/dsf/plugins/FilamentLoadCell/dsf/weigh This is the helper script and it needs to be executable.
At a command prompt: sudo ln -s /opt/dsf/plugins/FilamentLoadCell/dsf/weigh /usr/local/bin This is to make the helper script easily accessible.
With nothing on the spool holder at a command prompt run weigh zero, this records the tare reading of the holder alone.
Then you need something of a known weight not dissimilar to a spool of filament (preferably nearing the end) - I use a 200g weight - and run weigh calib. It will ask you what the weight is.
Then preferably put an empty spool on the holder and run weigh spool. If you don't have an empty spool but do know what one weighs you can run weigh manual and enter a weight value.
Some semi-cryptic entries should now have shown up in the spoolweigh.txt file in the system directory.
Now you should be able to start the plugin and get a weight readout.
I expect that installing an updated version of the plugin in future will require a repeat of teh subsequent steps above (or extracting the relevant lines from the spoolweigh.txt file first and then adding them into the new one, but probably easier to just redo the steps).