M502 returns array index error
-
Just noticed a curiosity.
If I run
M98 P"0:/sys/config.g"
I get no errors.However if I run M502 I get n array index out of bounds error for this code
;load config for filament if move.extruders[state.currentTool].filament="" echo "No filament loaded. Cold extrude & retract set to defaults" M302 S190 R110 ; Allow extrusion starting from 190°C and retractions already from 110°C (defaults) set global.LoadedFilament="No_Filament" else set global.LoadedFilament=move.extruders[state.currentTool].filament ; set the variable to the currently loaded filament echo "Loading config for " ^ global.LoadedFilament ^ " filament" M703 ; if a filament is loaded, set all the heats and speeds for it by loading config.g G4 P10
Attached is the complete config.g
It's not really causing me a problem, but I can't figure out why the results differ.
If I put an echo command it resolves correctly. -
@owend when M502 is run, T commands in config.g are not executed. I expect this causes state.currentTool to be -1 in the code you posted.
-
@dc42
That's what I initially thought, but if I put
echo state.currentTool on the line above it returns 0
Yet if I hard code the extruder object to zero it stops complaining, so it must be -1 somewhere in code/memoryI'll mark as solved with a
EDIT: 10 seconds after I posted it hit me.
It's because the heater was turned off using M568 A0
This has the effect of the tool index being -1 despite T0 being selected -