On Tue, Dec 13, 2016, at 06:52 AM, Gene Heskett wrote:
> On Tuesday 13 December 2016 04:35:44 andy pugh wrote:
> > Note that you can specify a thread position explicitly in the "addf"
> > command. I can't find it mentioned in the docs, but it is there in the
> > code
> > https://github.com/LinuxCNC/linuxcnc/blob/af15a4d90e1d51d5309db65fe1c9
> >511e486df411/src/hal/hal_lib.c#L1973

Oops, looks like that got left out of the man page.  It has been in the code
pretty much forever, and is documented in halcmd's built-in help, like so:

 } else if (strcmp(command, "addf") == 0) { 
printf("addf functname threadname [position]\n"); 
printf("  Adds function 'functname' to thread 'threadname'.  If\n"); 
printf("  'position' is specified, adds the function to that spot\n"); 
printf("  in the thread, otherwise adds it to the end.  Negative\n"); 
printf("  'position' means position with respect to the end of the\n"); 
printf("  thread.  For example '1' is start of thread, '-1' is the\n"); 
printf("  end of the thread, '-3' is third from the end.\n"); 
 
> I'd have to assume its a space/tab separated argument, from the code, 
> last in the string before any # identifying comments. And it opens the 
> door to even greater freedom in composing a .hal sequence of files in 
> the manner I described & you clipped. Planning ahead, I'll try to use 
> blocks of numbers that may leave gaps so there is room to go back later 
> and insert the gear change suggesting code in the intervening, still 
> unused numerical space in the thread execution order. I currently have 
> 78 in TLM's main hal file, so as a starter I'll use 1-20 for one 
> function, 21-40 for the next group. Wash rinse and repeat.  And find out 
> if it doesn't like missing numbers in the sequence.

It doesn't work that way.

The position is relative to the function list AS IT EXISTS at the moment 
the addf command is executed.  Functions are stored in a simple linked
list, not an array, so the concept of "empty spaces" doesn't exist.  Think
of index cards in a card file.  You can insert a new card between the 3rd
and 4th cards.  When you do, the old 4th card becomes the 5th card, and
the new card becomes the 4th one.  There are no numbers associated
with the cards - if you want to know which one is the 4th, you just start
at the front of the list and count.  If you want to know which one is 3rd
from the end you start at the end and count the other way.

If you have 5 functions in a thread at the moment you run an addf
command, the only legal values for "position" are -6 thru 6.  Positive
6 means 6th in the thread, so it counts off five from the front of the
list and inserts the new one after #5.  If you tried positive 7 it would
need to count off 6 from the front of the list.  There are only 5, so the
counting would hit the end of the list and throw an error message.

-- 
  John Kasunich
  jmkasun...@fastmail.fm

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to