@SamKudarauskas - DC42 has the failsafe method - an input to the Deut3D board that is triggered when a tool is in its dock. You'd also really want one on the carriage to tell you that a tool is mounted on the carriage. Then on power up, you can run a macro that asks if the switches tell you there is a tool on every dock and no tool on the carriage - normally expected state. If you found a tool on the carriage and only one dock missing a tool, you can infer where the tool goes. You run into a challenge if there is a tool on the carriage, and either more than one tool dock is empty (or none are). You should have a plan for that too.
The less-good way is to track which tool is on the carriage in a way that will survive a power cycle or emergency stop/restart. One good way to do this is to have a line at the beginning of each tpostN.g file and at the end of tfree.g that looks something like this:
echo >"0:/sys/which_tool.g" "global current_tool =", {state.currentTool}
I'm not positive the RRF fw has "-1" in State.currentTool at the end of tfree, so you should check. If it still has the "previous" tool number, then the tpre line should explicitly assign -1 to the global.
echo >"0:/sys/which_tool.g" "global current_tool =-1"
When this line runs, it creates a small macro file called "which_tool.g" in the sys directory, and overwrites any existing file. If my syntax is correct, when the which_tool.g file runs it'll create a global variable called current_tool with the last tool number in it.
Now you insert a line in your config.g
M98 P"0:/sys/which_tool.g"
At power up, the macro runs and creates the global variable. Now you can query it and know which what the last tool that was used. Of course. if the tool fell off the carriage, you won't know that unless you implement the switches above.
WHen this is