#linuxcnc-devel Logs
Apr 03 2018
#linuxcnc-devel Calendar
11:52 AM narogon: hi everyone
11:54 AM narogon: is there any way I could link "esc" key press with a hal pin?
11:55 AM jepler: pcw_home: I wrote patches to use /dev/spidev from mesaflash, but afaik rpi doesn't use /dev/spidev so .. probably not
11:55 AM cradek: narogon: tell us more about what problem you're wanting to solve?
11:56 AM narogon: I execute some M100 codes
11:57 AM narogon: and I have a finite state machine in a hal component that executes some actions with those M100
11:58 AM narogon: I need to capture the esc press to abort the actions of the FSM at the same time linuxcnc aborts the execution of the MDI
11:58 AM narogon: or g code program
11:58 AM narogon: maybe there is already a pin for it
11:58 AM seb_kuzminsky: narogon: there is :-)
11:59 AM seb_kuzminsky: it's motion.something, lemme look
12:01 PM narogon: ohh
12:01 PM seb_kuzminsky: you could maybe look at motion.motion-type or motion.motion-enabled, not sure which is more appropriate for your use case
12:01 PM narogon: I was looking halui pins
12:01 PM seb_kuzminsky: http://linuxcnc.org/docs/devel/html/man/man9/motion.9.html#MOTION PINS
12:01 PM narogon: there is also a motion.program-line
12:01 PM narogon: it is perfect por this
12:02 PM seb_kuzminsky: halui might have something usable too, but motion's pins should be preferred since it's realtime, halui is not so it can have lag
12:02 PM Tom_L: if it's from a sub will the program lines be accurate?
12:02 PM seb_kuzminsky: Tom_L: probably not :-/
12:03 PM narogon: well not perfect because I couldn't distinguish end of program from abort command
12:04 PM seb_kuzminsky: hmm, yeah i see what you mean
12:04 PM narogon: in any case
12:05 PM narogon: in my m100 codes I left the program stuck in a loop
12:05 PM narogon: until my fsm puts a end pin up
12:06 PM pcw_home: I wonder if any of the RPI clones use spidev
12:06 PM Tom_L: use an M66 in the sub maybe
12:07 PM narogon: so the fact is if my fsm hasn't ended the program the program-line must be greater than 0
12:07 PM seb_kuzminsky: i see that motion.program-line is totally undocumented :-(
12:08 PM narogon: Tom_L: no, I use this way until [ "$A" = TRUE ]; do A=$(halcmd getp fsm.endpin) sleep 0.2 done
12:11 PM Tom_itx: https://forum.linuxcnc.org/38-general-linuxcnc-questions/31547-motion-program-line-issue
12:15 PM Tom_itx: the 2.6 docs say a tiny bit more about it
12:16 PM Tom_L: wonder why that was omitted after that
12:19 PM narogon: if you execute a MDI command happens strange things with program-line
12:20 PM Tom_L: motion.program-line - (s32, out) The current program line while executing. Zero if not running or between lines while single stepping.
12:22 PM Tom_L: i don't think mdi is considered a program line
12:22 PM seb_kuzminsky: the motion manpage doesn't say anything (i checked 2.6 and later), but the "core components" page does
12:22 PM seb_kuzminsky: i just copied the words from the core component page to the manpage
12:22 PM Tom_L: yeah that's where i found it
12:23 PM Tom_L: i doubt mdi affects program-line though
12:23 PM narogon: if you execute a mdi with the example linuxcnc axis gcode
12:23 PM narogon: program-line is 200
12:23 PM narogon: if you load a different gcode
12:23 PM narogon: program-line with mdi execution is 0
12:24 PM seb_kuzminsky: i'd expect program-line to be a little meaningful when running a g-code program, and zero at all other times, is that what you see narogon?
12:27 PM narogon: no, program-line make sense when running a g-code (program-line pin is different to gcode code line due to only movements and so on represents a program line...) but with mdi command and "axis splash gcode" loaded (the default gcode program that comes with linuxcnc and axis) the program-line is 200
12:28 PM narogon: it's something strange that could be interesting to study
12:28 PM narogon: (to reproduce it, open axis sim, home, run mdi command and check program-line value)
12:29 PM narogon: so, any other idea to capture the abort command of the esc key
12:30 PM Tom_L: https://forum.linuxcnc.org/38-general-linuxcnc-questions/30206-a-axis-to-keyboard-shortcuts
12:30 PM seb_kuzminsky: i'm a little surprised that Abort doesn't send a termination signal to your M-code sprogram
12:31 PM narogon: it does, but my finite state machine hal component doesn't catch it
12:32 PM narogon: and it is who controls the outputs
12:32 PM rene-dev: I think the program line might go a bit crazy on remaps, be careful about that.
12:32 PM rene-dev: the run from line also doesnt work with remaps...
12:33 PM seb_kuzminsky: remaps got merged a little prematurely, then abandoned :-(
12:34 PM rene-dev: there is a lot of redundant code
12:35 PM narogon: the idea is: I execute M100 https://pastebin.com/X6ARnVjR
12:36 PM narogon: the FSM component start doing some actions, changing digital outputs and so on
12:36 PM narogon: if you press ESC linuxcnc aborts the M100 execution
12:37 PM narogon: but the FSM doesn't know it, so it continues doing the sequence. I need a signal that turns on with that abort command
12:37 PM seb_kuzminsky: you might use M62/M63 to set the StartSomething pin true, then use M66 to wait for SomethingEnded to go true, instead of doing it in your M100 script
12:38 PM seb_kuzminsky: http://linuxcnc.org/docs/devel/html/gcode/m-code.html#mcode:m66
12:38 PM seb_kuzminsky: http://linuxcnc.org/docs/devel/html/gcode/m-code.html#mcode:m62-m65
12:38 PM Tom_L: i suggested M66
12:38 PM Tom_L: dunno if that would work or not
12:39 PM seb_kuzminsky: oh, i see, your m100 script *does* get killed on Abort, but the flying spaghetti monster doesn't notice
12:39 PM seb_kuzminsky: could you use a die handler in m100 to set an "aborted" pin on the fsm?
01:09 PM narogon: function ended { echo "ended" halcmd setp fsm.M100ended True halcmd setp fsm.M100ended False } trap ended SIGINT SIGTERM
01:09 PM narogon: seb_kuzminsky this works
01:09 PM seb_kuzminsky: yay!
01:14 PM stustev: cradek: I still don't see where the 'AC' interpreter is limited to AC - sigh
01:15 PM cradek: stustev: did you diff the special one and the normal one?
01:15 PM cradek: (can you give me the url for the special one again?)
03:01 PM narogon: thanks tom and seb!
03:07 PM KimK: cradek: I think stustev might be busy, was this the URL you were looking for? https://github.com/emogenet/rs274ngc
03:25 PM cradek: Hm I'm not sure.
03:30 PM cradek: ok yeah, I found it in scrollback too. This code isn't from linuxcnc, it's from a distant ancestor
03:31 PM cradek: it looks like you can build it with A and C axes defined, but not B. That affects the output (like a FEED command will have 5 coordinates instead of 6, or 9 like in linuxcnc)
03:31 PM cradek: it could be the other program expects that and fails otherwise
03:46 PM stustev: cradek: ok then - it looks as if it is time for me to look again to see if I can follow the logic - will do and then report back :)
04:57 PM jepler: cradek: rs274ngc_pre calls GET_EXTERNAL_AXIS_MASK and then cheeses the parsers for the characters that correspond to non-available axes
04:58 PM jepler: so if you send in an axis mask like 057 you'd get an XYZAC machine.
04:58 PM jepler: s274ngc_pre.cc: long axis_mask = GET_EXTERNAL_AXIS_MASK();
04:58 PM jepler: rs274ngc_pre.cc: if(!(axis_mask & AXIS_MASK_X)) _readers[(int)'x'] = 0;rs274ngc_pre.cc: long axis_mask = GET_EXTERNAL_AXIS_MASK();
04:58 PM jepler: rs274ngc_pre.cc: if(!(axis_mask & AXIS_MASK_X)) _readers[(int)'x'] = 0;
04:58 PM jepler: whoops excuse the bad paste