Skip to content

Add configurable action command to send when printer is killed #7217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2017

Conversation

benlye
Copy link
Contributor

@benlye benlye commented Jul 2, 2017

Sends user-defined string as action command when printer is killed.

Spawned from conversation in #7137, where a couple of people thought that informing a connected host that the printer has been killed in a user-configurable, language agnostic, way would be useful.

I'm sure there are other action commands which it would be useful for the printer to send, but a 'kill' action is the one which seems most useful to me. With that in mind, I couldn't decide if the variable should be KILL_ACTION, which groks easier, or ACTION_KILL, which lends itself to being in a list of other action definitions. I don't feel strongly either way.

@Roxy-3D
Copy link
Member

Roxy-3D commented Jul 2, 2017

USER_SPECIFIED_ACTION_AT_KILL leaves very little doubt about what is being specified and when it will be invoked. For something as important as this... It doesn't bother me to have a slightly longish name.

@fiveangle
Copy link
Contributor

But I do see how having all ACTION_* strings in a common location useful, and prefixing with "USER_SPECIFIED_ACTION" doesn't really lend itself well toward finding if someone is looking for "ACTION" items (which is what other host software like Repeteir and Octoprint lump them into).

I do like ACTION_AT_KILL (since ACTION_AT_SUICIDE as per some existing internal values seems a bit melodramatic ;)

@Roxy-3D
Copy link
Member

Roxy-3D commented Jul 3, 2017

Yes. You are correct...

I don't really care what the name is. But I want it very obvious what it means when it shows up in the code some where. Let's not skimp on characters for the name just to make it short. I prefer something like this is very very obvious!

And if the user presses the Kill button on the LCD Panel, it isn't a 'Suicide'. The firmware didn't kill itself. :)

Copy link
Member

@thinkyhead thinkyhead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor changes needed…

* Will be sent in the form '//action:KILL_ACTION', e.g. '//action:poweroff'.
* The host must be configured to handle the action command.
*/
//#define KILL_ACTION "poweroff"
Copy link
Member

@thinkyhead thinkyhead Jul 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clone these lines to the same position in all Configuration_adv.h files in example_configurations. The easiest way is to globally replace the unique lines that precede this addition with those same lines, plus this addition.

Copy link
Contributor Author

@benlye benlye Jul 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do - wanted to have the conversation about the parameter name before I went and edited a bunch of files. ACTION_ON_KILL seems good to me. Do you have a preference?

@@ -12836,6 +12836,10 @@ void kill(const char* lcd_msg) {
_delay_ms(250); //Wait to ensure all interrupts routines stopped
thermalManager.disable_all_heaters(); //turn off heaters again

#if defined(KILL_ACTION)
SERIAL_ECHOLNPAIR("//action:", KILL_ACTION);
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use this instead to save on SRAM:

SERIAL_ECHOLNPGM("//action:" KILL_ACTION);

@benlye
Copy link
Contributor Author

benlye commented Jul 3, 2017

Not to be pedantic, but ACTION_ON_KILL sounds better to me than ACTION_AT_KILL, and I think that syntax will work well for any future action commands. I'm ready to update the PR with @thinkyhead's changes and the revised name as soon as there is consensus.

@fiveangle
Copy link
Contributor

fiveangle commented Jul 3, 2017

ACTION_ON_KILL sounds better to me than ACTION_AT_KILL

Agreed. But it looks like Scott doesn't want to change the string name throughout ? Maybe make the change as he describes for now, and if the action commands take off, we can revisit renaming so all actions are prefixed with "ACTION_" at a later time ?

EDIT: I see that Scott's comments were only to omit the comma operator from the SERIAL_ECHOLNPAIR to save SRAM, so I think you're good to go for ACTION_ON_KILL.

@fiveangle
Copy link
Contributor

fiveangle commented Jul 3, 2017

But I want it very obvious what it means when it shows up in the code some where.

To @Roxy-3D 's point, the ACTION is a host feature class that probably deserves some form of simple documentation on the wiki. @benlye - do you have an idea on where you could inject this info ? Also, your new Mcode probably needs an entry ?

ps- I don't think others realize the possibilites this opens up. Nice work 🥇

Sends pre-defined string as action command when printer is kill.
@benlye benlye force-pushed the add-kill-action branch from 6d11ffc to c28749a Compare July 3, 2017 22:45
@benlye
Copy link
Contributor Author

benlye commented Jul 3, 2017

I've changed the serial out method to SERIAL_ECHOLNPGM, made the modification to all the configuration_adv.h example files, and in the absence of any other feedback I went ahead and changed the parameter name to ACTION_ON_KILL.

@thinkyhead
Copy link
Member

thinkyhead commented Jul 4, 2017

This is a great contribution, simple as it is. Thanks!

Perhaps we ought to also add "CAP:HOST_ACTIONS:1" to M115 output when this is enabled.

If it seems like "HOST_ACTIONS" isn't needed, that's fine. A host will or will not respond to action strings based on its own settings, and probably doesn't need to be pre-warned to expect them.

@thinkyhead thinkyhead merged commit a2babb5 into MarlinFirmware:bugfix-1.1.x Jul 4, 2017
@benlye benlye deleted the add-kill-action branch July 5, 2017 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants