HAL names - 16 argument limit?
25 Jan 2019 15:33 #124823
by mjohnston
HAL names - 16 argument limit? was created by mjohnston
Hi all,
I've run into an issue with my HAL files for a project I'm working on. When using "loadrt and2 names=", it seems that listing more than 16 names causes the insmod call to fail, resulting in none of those HAL components being created. I don't think this is specific to and2, but maybe it is. See below for a command line printout showing the error. I'm assuming the 16 argument limit is hard-coded somewhere, but is there any way around it?
Some background: for what I'm trying to do, using names instead of count is necessary. I'm trying to split out some basic logic and timers into a separate HAL file, which requires using twopass to load all the components common to both files (like and2). I don't want to have to rewrite an entire file if the number of and2's (or any shared component) in the first file changes. I have been using classicladder for this logic up until now, but I wanted to move it to HAL to simplify things a bit - one less 'program' to maintain, and it's a little cumbersome that you need an operational LinuxCNC instance running in order to edit the ladder.
I've run into an issue with my HAL files for a project I'm working on. When using "loadrt and2 names=", it seems that listing more than 16 names causes the insmod call to fail, resulting in none of those HAL components being created. I don't think this is specific to and2, but maybe it is. See below for a command line printout showing the error. I'm assuming the 16 argument limit is hard-coded somewhere, but is there any way around it?
Some background: for what I'm trying to do, using names instead of count is necessary. I'm trying to split out some basic logic and timers into a separate HAL file, which requires using twopass to load all the components common to both files (like and2). I don't want to have to rewrite an entire file if the number of and2's (or any shared component) in the first file changes. I have been using classicladder for this logic up until now, but I wanted to move it to HAL to simplify things a bit - one less 'program' to maintain, and it's a little cumbersome that you need an operational LinuxCNC instance running in order to edit the ladder.
names=and2.0,and2.1,and2.2,and2.3,and2.4,and2.5,and2.6,and2.7,and2.8,and2.9,and2.10,and2.11,and2.12,and2.x1.fault,and2.x2.fault,and2.y.fault,and2.z.fault,and2.c.fault,and2.s1.fault.0,and2.s1.fault.1,and2.fault,and2.es.act,and2.es.reset,and2.s1.act,and2.s2.act,and2.s.on,and2.s.noton,and2.ll.on,and2.ll.off: can only take 16 arguments
twopass: load_the_modules cmd=<orig_loadrt and2 names=and2.0,and2.1,and2.2,and2.3,and2.4,and2.5,and2.6,and2.7,and2.8,and2.9,and2.10,and2.11,and2.12,and2.x1.fault,and2.x2.fault,and2.y.fault,and2.z.fault,and2.c.fault,and2.s1.fault.0,and2.s1.fault.1,and2.fault,and2.es.act,and2.es.reset,and2.s1.act,and2.s2.act,and2.s.on,and2.s.noton,and2.ll.on,and2.ll.off>
waitpid failed /usr/bin/rtapi_app and2
/usr/bin/rtapi_app exited without becoming ready
insmod for and2 failed, returned -1
creating ladder-state
HAL: ERROR: function 'and2.0' not found
twopass: Error in file ./customspray.hal:
addf failed
Please Log in or Create an account to join the conversation.
25 Jan 2019 18:31 - 25 Jan 2019 18:40 #124845
by dgarrett
The limit of 16 for names= instances is set by halcompile.
The 16 value is hardcoded in a number of places in halcompile.g:
github.com/LinuxCNC/linuxcnc/blob/master...l/utils/halcompile.g
Some possible solutions for a RIP build:
1) handedit the 16 value in appropriate places in halcompile.g, then rebuild
2) to make a little easier, i've made a branch that
parameterizes the number of names= instances so you just edit in
one place (MAX_NAMES=)
(this branch could likely be merged to master if sufficiently tested)
Ref: github.com/LinuxCNC/linuxcnc/commits/dgarr/halcompile_max_names
Commit: github.com/LinuxCNC/linuxcnc/commit/0eb1...8256f79de07c0a5f2b26
For a deb install, you could build some additional
components using halcompile that replicate the and2.comp
with different file/component names:
you then can use 16 name= instances of and2
and 16 name= instances of myand2
Replied by dgarrett on topic HAL names - 16 argument limit?
it seems that listing more than 16 names causes the
insmod call to fail
The limit of 16 for names= instances is set by halcompile.
The 16 value is hardcoded in a number of places in halcompile.g:
github.com/LinuxCNC/linuxcnc/blob/master...l/utils/halcompile.g
Some possible solutions for a RIP build:
1) handedit the 16 value in appropriate places in halcompile.g, then rebuild
2) to make a little easier, i've made a branch that
parameterizes the number of names= instances so you just edit in
one place (MAX_NAMES=)
(this branch could likely be merged to master if sufficiently tested)
Ref: github.com/LinuxCNC/linuxcnc/commits/dgarr/halcompile_max_names
Commit: github.com/LinuxCNC/linuxcnc/commit/0eb1...8256f79de07c0a5f2b26
For a deb install, you could build some additional
components using halcompile that replicate the and2.comp
with different file/component names:
cp and2.comp myand2.comp
edit myand2.comp to make the component name myand2
(the component name inside the .comp file should agree with
the file name)
sudo halcompile --install myand2.comp
you then can use 16 name= instances of and2
and 16 name= instances of myand2
Last edit: 25 Jan 2019 18:40 by dgarrett.
The following user(s) said Thank You: Mike_Eitel, mjohnston
Please Log in or Create an account to join the conversation.
- Mike_Eitel
- Offline
- Platinum Member
Less
More
- Posts: 1150
- Thank you received: 184
25 Jan 2019 20:50 #124856
by Mike_Eitel
Replied by Mike_Eitel on topic HAL names - 16 argument limit?
Now I understand.
I run recently into the same with two many and2. Solved it by inverted logic, but it looks odd.
Is that restriction somewhere in the docs.
THX
I run recently into the same with two many and2. Solved it by inverted logic, but it looks odd.
Is that restriction somewhere in the docs.
THX
Please Log in or Create an account to join the conversation.
25 Jan 2019 21:00 - 25 Jan 2019 21:02 #124857
by mjohnston
Replied by mjohnston on topic HAL names - 16 argument limit?
dgarret, thanks for the answer! I suspected it was something like that, but it's good to know for sure. I would say that change should be pulled (magic numbers are bad!), but that's not up to me. Now I just need to decide which way I want to solve it in the mean time...
Mike, I didn't find mention of the 16 instance limit in the docs, but I also skimmed a lot.
Looking at halcompile.g, it looks like the same limit will apply to any HAL component that uses a personality (e.g. logic or lut5).Is there any hidden downside to increasing the max number of named instances? The fact that you can exceed that limit by using count= suggests to me that there isn't, someone just had to pick a number at some point in the past.
Edit: It's true that having more than 16 names and personalities on one line of a HAL file would be very cumbersome to read. However, that can be mitigated by splitting it into multiple loadrt lines and turning TWOPASS = on in the ini file, so that isn't a real limitation IMO.
Mike, I didn't find mention of the 16 instance limit in the docs, but I also skimmed a lot.
Looking at halcompile.g, it looks like the same limit will apply to any HAL component that uses a personality (e.g. logic or lut5).Is there any hidden downside to increasing the max number of named instances? The fact that you can exceed that limit by using count= suggests to me that there isn't, someone just had to pick a number at some point in the past.
Edit: It's true that having more than 16 names and personalities on one line of a HAL file would be very cumbersome to read. However, that can be mitigated by splitting it into multiple loadrt lines and turning TWOPASS = on in the ini file, so that isn't a real limitation IMO.
Last edit: 25 Jan 2019 21:02 by mjohnston.
Please Log in or Create an account to join the conversation.
- Mike_Eitel
- Offline
- Platinum Member
Less
More
- Posts: 1150
- Thank you received: 184
25 Jan 2019 21:07 #124858
by Mike_Eitel
Replied by Mike_Eitel on topic HAL names - 16 argument limit?
I'm using always names, multiple hal and twopass.
Doesn't matter in with file.
It did not work.
Mike
Doesn't matter in with file.
It did not work.
Mike
Please Log in or Create an account to join the conversation.
28 Jan 2019 19:02 #125086
by mjohnston
Replied by mjohnston on topic HAL names - 16 argument limit?
Sorry, Mike, I guess I could've formatted my post a bit better. My last two paragraphs were meant to be just a discussion of the source code, not a solution to the issue.
As far as I can see, the only solutions for now are what dgarrett mentioned in his post.
As far as I can see, the only solutions for now are what dgarrett mentioned in his post.
Please Log in or Create an account to join the conversation.
- Mike_Eitel
- Offline
- Platinum Member
Less
More
- Posts: 1150
- Thank you received: 184
28 Jan 2019 21:08 #125098
by Mike_Eitel
Replied by Mike_Eitel on topic HAL names - 16 argument limit?
Nope, no misunderstanding, just clarification of bounderies.
And yes, if it has no side effects, I would prefer to see final 2.8 with bigger number than 16. At least in dimple logic elements like and / or etc.
m5c
Mike
And yes, if it has no side effects, I would prefer to see final 2.8 with bigger number than 16. At least in dimple logic elements like and / or etc.
m5c
Mike
The following user(s) said Thank You: Nico2017
Please Log in or Create an account to join the conversation.
01 Feb 2019 15:08 #125476
by dgarrett
Replied by dgarrett on topic HAL names - 16 argument limit?
Please Log in or Create an account to join the conversation.
04 Feb 2019 03:37 #125630
by Nico2017
Replied by Nico2017 on topic HAL names - 16 argument limit?
Mhmm,
actually when I also use count definition I would face the 16 items limitation. For instance with
loadrt logic count=17 personality=0x103,0x203,0x1003,0x1003,0x108,0x108,0x106,0x106,0x803,0x108,0x203,0x107,0x107,0x107,0x106,0x106,0x203
So the 16 items limitation has been reach here using the count feature.
logic is actually useful when you start to have safety on some of your features machine so I guess it is actually easy to reach this limitation.
As Mike is saying, would be nice if it has no side effects [...] to see final 2.8 with bigger number than 16
Nicolas
actually when I also use count definition I would face the 16 items limitation. For instance with
loadrt logic count=17 personality=0x103,0x203,0x1003,0x1003,0x108,0x108,0x106,0x106,0x803,0x108,0x203,0x107,0x107,0x107,0x106,0x106,0x203
So the 16 items limitation has been reach here using the count feature.
logic is actually useful when you start to have safety on some of your features machine so I guess it is actually easy to reach this limitation.
As Mike is saying, would be nice if it has no side effects [...] to see final 2.8 with bigger number than 16
Nicolas
Please Log in or Create an account to join the conversation.
11 Feb 2019 19:21 #126214
by mjohnston
Replied by mjohnston on topic HAL names - 16 argument limit?
Nicolas,
I believe it is actually the personality parameter that has the 16 item limitation. If you use for example
loadrt and2 count=20
it will succeed. Of course that doesn't help if you're trying to use the logic component, since personality is essentially required then.
I believe it is actually the personality parameter that has the 16 item limitation. If you use for example
loadrt and2 count=20
it will succeed. Of course that doesn't help if you're trying to use the logic component, since personality is essentially required then.
The following user(s) said Thank You: Nico2017
Please Log in or Create an account to join the conversation.
Time to create page: 0.186 seconds