Unexpected behaviour of expression { } in command parameters.
-
@dc42 said in Unexpected behaviour of expression { } in command parameters.:
@adegtiar I have updated https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands#Section_Use_of_expressions_within_GCode_commands to show the correct syntax.
I have tried that syntax, but got an error:
M581 T9 R0 S1 P{global.x_axis_endstop_pin, global.y_axis_left_endstop_pin, global.y_axis_right_endstop_pin, global.z_axis_endstop_pin} Error: M581: expected '}'
-
@adegtiar there should be + in between , not a ,
-
@jay_s_uk said in Unexpected behaviour of expression { } in command parameters.:
@adegtiar there should be + in between , not a ,
Thank you! It works
-
Returning to the question, I found that the solution still does not work.
Tested on Firmware: RepRapFirmware for Duet 2 WiFi/Ethernet 3.4.0 (2022-03-15)
Operator '+' just summarizes pins values and as result I have one pin number 30 instead of 4 pins (6:7:8:9)
G-CODE to reproduce
; Variables global x_axis_endstop_pin = 6 global y_axis_left_endstop_pin = 7 global y_axis_right_endstop_pin = 8 global z_axis_endstop_pin = 9 ; remove all pins from trigger M581 T9 P-1 ; check the trigger configuration M581 T9 Result: Trigger 9 is not configured ; setup new pins M581 T9 R0 S1 P{global.x_axis_endstop_pin + global.y_axis_left_endstop_pin + global.y_axis_right_endstop_pin + global.z_axis_endstop_pin} ; check what we have M581 T9 Result: Trigger 9 fires on a rising edge of endstops/inputs 30
-
@wackyfrog the M581 P parameter is a single string so you need to concatenate the various parts using ^. Try this:
M581 T9 R0 S1 P{global.x_axis_endstop_pin ^ "+" ^ global.y_axis_left_endstop_pin ^ "+" ^ global.y_axis_right_endstop_pin ^ "+" ^ global.z_axis_endstop_pin}
-
@dc42 I've got the error:
M581 T9 R0 S1 P{global.x_axis_endstop_pin ^ "+" ^ global.y_axis_left_endstop_pin ^ "+" ^ global.y_axis_right_endstop_pin ^ "+" ^ global.z_axis_endstop_pin} Error: M581: expected integer value
-
As a workaround, I'm currently using the code below, but I would like to figure out how to correctly pass multiple values using variables in such parameters.
M581 T9 P-1 M581 T9 R0 S1 P{global.x_axis_endstop_pin} M581 T9 R0 S1 P{global.y_axis_left_endstop_pin} M581 T9 R0 S1 P{global.y_axis_right_endstop_pin} M581 T9 R0 S1 P{global.z_axis_endstop_pin} M581 T9 Result: Trigger 9 fires on a rising edge of endstops/inputs 6 7 8 9
-
@wackyfrog I'm sorry, I made a mistake. In RRF 3.4 the M581 P parameter is a list of pin numbers that you created using M950 with the J parameter. So this command from your earlier post should work under firmware 3.4:
M581 T9 R0 S1 P{global.x_axis_endstop_pin, global.y_axis_left_endstop_pin, global.y_axis_right_endstop_pin, global.z_axis_endstop_pin}
But I've just tested it, and I get the same error that you reported. I am investigating why.
-
@wackyfrog I found and fixed the problem. The fix will be in the 3.4.1 release.
-
@dc42 Thanks, David!