variable to objects are pointers or something like that
-
Hi. Im doing some macros. Im on a filament change macro, so in filament-change.g I have:
M25
set global.filament = {move.extruders[0].filament}
M702 S{global.filament} ; descarga filament actual
M400
M701 S{global.filament}My intention here is to react when the filament run out sensor triggers. So I unload the loeaded material and reload the same material , that is why I assign the name of tjhe material to a global variable.
This macro is working on the unload part, I have checked that initial global variable is done properly, but when M701 S{global.filamento} is executed I get and error saying Error: in file macro line 5: M701: non-empty string expectedSo looks like the global variable was updated like if it is a pinter to the object in memory.
Any way to work around this?Thanks in advance
-
@Tinchus said in variable to objects are pointers or something like that:
set global.filament = {move.extruders[0].filament}
......................
M701 S{global.filament}.........................but when M701 S{global.filamento} is executed I get and error saying Error: in file macro line 5: M701: non-empty string expected
It might just be a typo in your post but in your macro you refer to "global.filament" but later on when you describe the problem, you refer to "global.filamento" (an extra "o"). Does your actual macro refer to the correct global name?
-
@deckingman Sorry, just a typo on the post, the code is the one I pasted on top:
M25
set global.filament = {move.extruders[0].filament}
M702 S{global.filament}
M400
M701 S{global.filament} -
@Tinchus I suspect that you haven't defined the filament for extruders[0] when you run the macro, so global.filament is getting set to an empty string. The M701 command requires a non-empty string as the error message says.
The M702 command takes no parameters, so the S parameter you are providing t that command will be ignored. In which case you shold perhaps use this (not tested):
M25 set global.filament = {move.extruders[0].filament} M702 ; descarga filament actual M400 if global.filament != "" M701 S{global.filament}
-
@dc42 thanks for the info.I will test this onece back at the school.
What I dindn{t include on the post was all the "debugging" stuff I was using. This is what it is doing :
M25 >>>>>> do the pause, ok
set global.filament = {move.extruders[0].filament} >>>>> at this moment I can read on interface "ABS"
echo global.filament >>>>>> this shows me the value ABS, as expected, so till here the variable has the correct value
M702 S{global.filament} ; descarga filament actual >>>>>> this unloads the material.
M400 >>>>> not sure is needed, intention is to not continue with exewcution till all unload movements are doneM701 S{global.filament} >>>>>> here it is my problem, this global was assigned at the very start of the macro, the echo command confirmed me that the value was "ABS". So I was thinking the global was still having a value of "ABS". But it daesn´t . looking at the objects tree, I can see the global variable having a value of "".
It is like after executing the unload.g belonging to the filament loaded, the gloabl variable is updated? (just like a volatile declaration on C for example, or like a pointer?)
-
@Tinchus which firmware version are you using?
-
@dc42 DSF Version: 3.4.6
Firmware: RepRapFirmware for Duet 3 MB6HC 3.4.6 -
@Tinchus what happens if you change the line to:
set global.filament = move.extruders[0].filament^""