Hi Xavi
set up an input and an output in ports n pins and then
if your gcode looked something like this:
G1 X100
M666
G1 Y100
M666
G1 X0
M30
and you created a macro called M666.m1s that looked something like this:
'signal network analyser with say a 100 ms pulse
activateSignal(OUTPUT3)
sleep 100
deactivateSignal(OUTPUT3)
'here the analyser does it's thing and then activates an input pulse when it's done
While Not isActive(INPUT4) 'Mach waits for the incoming handshake from the analyser
sleep 100
Wend
'macro ends and the next gcode commanded movement is free to go
that should get you started if I've understood your requirement correctly
Cheers
Ian