Looking at your file, I donât think weâre doing it wrong, I think your postprocessor is.
The g-code standard for M6 commands is that it changes to either the T command on the same line as the M6, or the last T command issued before that M6 if one isnât on the same line.
See LinuxCNC standard: M-Codes
Your file issues a T21 early, some movement, then a M5 M6 on one line (with no T command) and the a T10 on a following line.
So what youâre seeing makes sense - the first M6 encountered has no T command on the same line, so it prompts you for the last T command sent (T21). The T10 on the line after the M6 is never reached - tool changing doesnât look ahead, again reference the standard.
Youâd need to have a M6 T21 and a M6 T10 (with the T10 on the same line as the M6) if you want the initial prompt for first tool and a second prompt to change to T10.
