@dc42 said in M104 with inactive tool puts heater in standby mode:
I think I see what you are saying, it's that in a dual heater machine the heater will be in standby mode, so when the call to SetToolHeaterStandbyTemperature sets the standby temperature it will affect the heater setpoint; but in a shared nozzle machine the heater will be in active mode so it won't.
Exactly
However, if a slicer sends a M104 command near the start of the file to put the second tool on standby when it was previously off, then your proposed change would still set the heater to standby temperature - which is wrong if it is being used by the active tool. So I think it doesn't quite fix all instances of the problem.
Yes it is possible. But first it is unlikely to happen - usual flow I believe is to issue M104 to inactive tool for it to heat in background and then M109 to active one to wait for it to reach. But even if that is the case solution for this case is very simple and straightforward - just send inactive tool M104 command (or newer Gnn command) in printer startup code. This is very simple step and nothing comparing to find every instance of M104 in middle of printing and remove it. And could be just documented in Wiki for multiextruder/shared nozzle setup.
On another side calling StandbyTool on standby state does not sound right, and usually it leads to problems sooner or later (what is actually happened in this case). If I would develop it I would write it like this:
void Tool::Standby()
{
if( state == ToolState::standby )
return;
...
but of course would do that in the beginning of developing, doing so now would be too dangerous for possible side effects. If you would want to hear my opinion I think cleaner solution would be to check from which state Tool is coming from and if it is off then it would also check every heater state and only apply state transition if it is in the same state. Probably the same for active to standby or standby to active transition as well. So something like this:
void Tool::Standby()
{
if( state == ToolState::standby )
return;
for( auto heater : heaters ) {
if( heater->GetState() == state ) heater->standby();
}
state = ToolState::standby;
}
this is more pseudocode, but I think idea is clear. But again most probably it is not the good time to do it now when there are many parts depends on current behavior and in current situation changes in M104 section seems to be the smallest change which should have minimal side effects and pretty easy to test.
Thanks,
Slava