[DSF Extension] Exec On MCode (was: Shutdown SBC)
Shutdown SBC v1.0
A small extension to listen for a user-defined
M7722by default) to then initiate a clean shutdown of the SBC (it simply executes
poweroff- and since it's usually run as
rootthat will work).
It can be found at GitHub Releases page.
$ shutdownsbc --help Usage of shutdownsbc: -shutdownMCode int Code that will initiate shutdown of the SBC (default 7722) -socketPath string Path to socket (default "/var/run/duet.sock")
- Rename to just
- Make executable with
chmod +x shutdownsbc
- Put it into any path in your
- Run it as
- Optional: use the
shutdownsbc.servicesystemd unit (included in the repo) to run it at startup
You can find it at https://github.com/wilriker/dsfext-shutdownsbc
As always I welcome any kind of contribution here or over at GitHub. Comments, suggestions, bug reports, Pull Requests, whatsoever. Everything is appreciated.
Exec On MCode v2.0
After a request on GitHub to also make the command to run configurable I have renamed the whole project to
execonmcodeand created a new release that will make the command configurable.
It will also report the outcome of the command (success, error) back to DuetSoftwareFramework.
As usual it can be found at GitHub Releases page.
$ ./execonmcode --help Usage of ./execonmcode: -command string Command to execute -mCode int Code that will initiate execution of the command (default 7722) -socketPath string Path to socket (default "/var/run/duet.sock")
@wilriker Great work, the plugin works just as it should!
We're using it to build a 'move backwards in gcode' function. However, it would be great if we could bring variables into the command string, maybe that could be solved by giving the M code S, P and Q parameters that would translate into $S, $P and $Q?
@too Thanks! I saw your GitHub issue but was a bit busy the last days. Sorry for not getting back to you sooner. Also great to hear that it is actually used by someone other than myself.
I'll think about how to do that best.
@wilriker Now RRF3 just needs to be working smooth with some of the more exotic features and the system would be near perfection
@dc42 looking forward!
This release provides parameter substitution. Please see the below for details on how to use it.
It can be found at the GitHub Releases page.
execonmcodedoes provide a simple mechanism for parameter substitution. It is possible to pass string parameters to the
M-Codeand have them inserted in the
-command. In the command string they have to be single letters prefixed by
the percent-sign (
%) and they must not be
All parameters that do not have a corresponding value in the
M-Codewill be forwarded as given.
$ ./execonmcode -command "mycommand %F %N %D"
Then you can use the following
M-Codesyntax to replace these parameters
M7722 F"my first parameter" N"my second parameter"
this will lead to an execution of
mycommand "my first parameter" "my second parameter" %D
%Dwas passed as is since it was not given in the
Just as a short teaser: the upcoming version will allow an arbitrary amount of
tobias_munich last edited by
great Job !! many thanks.
exactly what I looked for
This release adds the possibility to provide an arbitrary amount of
-commandtuples. This way it is possible to have a single instance of
execonmcodehandle all the custom commands.
Note that as part of this change there is no longer a default value for
Get it at GitHub Releases page.
EDIT: This version is built agains
goduetapiclient1.2.0 and as such will only work with DSF 126.96.36.199 and later. In case you need a version that is working with DSF <= 188.8.131.52 please tell me here. It's not a problem to provide that as well.
gtj0 last edited by
@wilriker I can't believe I missed this whole thread! Gonna give it a try tomorrow.
I'm also working on something to allow the SBC to do a hardware reset and flash erase via GPIO pins for cases where the firmware is stuck and you can't get to the board. Could be a good companion to your utility.
@gtj0 Glad to hear about any use-cases.
I myself use it to run
poweroffas well as activating and deactivating my webcam (starting/stopping a
A Former User last edited by
Tempting to try with a small I2C OLED on the Pi, but not top of the list just yet
This sounds really good. I would like to use it to activate a bash script on my system but I have attempted to install it and I cant get it to work.
I followed your instructions in your first post but using execonmode V3:
I downloaded execonmode and placed it into /usr/local/bin.
I tried to run it using sudo ./execonmode -help (just to see if it works) but I get the error message "cant open binary".
Could you instruct me where i'm going wrong.
BTW I am on the latest version of RRF3 and up to date with DSF etc.
Thanks in advance.
@chas2706 If you run
sudo ./execonmcode -help
It will try to find the executable in the current directory you issue this command. To have your shell locate it in your
./in front of
-helpyou don't need
To make sure that it can find it also check if
actually does contain
Last thing: you spelled it
execonmcode(extra "c" after "m") above. Make sure that's only a typo here. I might rename the executable in the future to something less error-prone.
Thanks for the info. I will give it another go.
execonmode was just a typo error in my post lol.
I have placed execonmcode in /usr/local/bin and typed the following in the terminal without success:
pi@Duet3:~ $ cd /usr/local/bin
pi@Duet3:/usr/local/bin $ ls
pi@Duet3:/usr/local/bin $ ./execonmcode -help
bash: ./execonmcode: Permission denied
pi@Duet3:/usr/local/bin $ sudo ./execonmcode -help
sudo: ./execonmcode: command not found
pi@Duet3:/usr/local/bin $ execonmcode -help
bash: /usr/local/bin/execonmcode: Permission denied
pi@Duet3:/usr/local/bin $ sudo execonmcode -help
sudo: execonmcode: command not found
@chas2706 Have you made
sudo chmod +x /usr/local/bin/execonmcode? I think that's missing from the installation instructions.
No I forgot!!
My silly mistake! It works a treat now.
Thank you for your help.
@chas2706 Thank you for implicitly pointing out a hole in the installation instructions. I amended that to GitHub already and will fix it above in an instant.
No problem, again thanks for your help and for producing a fantastic plugin.
The current version of Exec On MCode is NOT compatible with DSF 1.3.0+. It will connect but fail at a random point in time which might lead to breaking side-effects. I will release a new version tomorrow or Monday. Until then, don't use this tool with DSF 1.3.0+.