- Posts: 210
- Thank you received: 15
(SOLVED - maybe) How to get an underscore in a pin/parameter name?
- Sparky961
- Offline
- Elite Member
-
Less
More
8 years 4 months ago - 8 years 4 months ago #112331
by Sparky961
(SOLVED - maybe) How to get an underscore in a pin/parameter name? was created by Sparky961
I'm experimenting with creating a component that defines the pins for a Mesa 7i76e so that I can perform offline development and some testing. I'm not trying to emulate the functionality at this time, just having the definitions so the config will run.
I'm butting heads with a brick wall trying to get my first definition working, as it contains an underscore character and this appears to be treated specially by halcompile.
I want the parameter name exactly as above, but no matter what I try I can't get it to contain an underscore. Am I attempting the impossible or missing something?
The page below has not been of much help with this:
linuxcnc.org/docs/html/hal/comp.html
Thanks..
I'm butting heads with a brick wall trying to get my first definition working, as it contains an underscore character and this appears to be treated specially by halcompile.
Code:
component hm2_7i76e "Fake pins from 7i76e for testing without attached hardware";
param r s32 watchdog.timeout_ns = 5000000;
pin out bit out0;
pin in bit in0;
function _;
license "GPL";
;;
FUNCTION(_) {
out0 = in0;
}
I want the parameter name exactly as above, but no matter what I try I can't get it to contain an underscore. Am I attempting the impossible or missing something?
The page below has not been of much help with this:
linuxcnc.org/docs/html/hal/comp.html
Thanks..
Last edit: 8 years 4 months ago by Sparky961.
The following user(s) said Thank You: Mike_Eitel
Please Log in or Create an account to join the conversation.
- ozzyrob
- Visitor
-
8 years 4 months ago #112334
by ozzyrob
Replied by ozzyrob on topic How to get an underscore in a pin/parameter name?
HALNAME - An extended identifier. When used to create a HAL identifier, any underscores are replaced with dashes, and any trailing dash or period is removed, so that "this_name_" will be turned into "this-name"
From your code using halcompile --install
So it looks like you will have to accept any underscores _ are converted to - dashes.
From your code using halcompile --install
Code:
halcmd: loadrt hm2_7i76e
Note: Using POSIX realtime
halcmd: show pin
Component Pins:
Owner Type Dir Value Name
6 bit IN FALSE hm2-7i76e.0.in0
6 bit OUT FALSE hm2-7i76e.0.out0
6 s32 OUT 0 hm2-7i76e.0.time
So it looks like you will have to accept any underscores _ are converted to - dashes.
Please Log in or Create an account to join the conversation.
- Sparky961
- Offline
- Elite Member
-
Less
More
- Posts: 210
- Thank you received: 15
8 years 4 months ago #112337
by Sparky961
Replied by Sparky961 on topic How to get an underscore in a pin/parameter name?
Can I thus reason that the real component/driver for this generates the names with underscores because it's written in C ?
Maybe this side project is a non-starter. It seemed like it would be simple.
Maybe this side project is a non-starter. It seemed like it would be simple.
Please Log in or Create an account to join the conversation.
- ozzyrob
- Visitor
-
8 years 4 months ago - 8 years 4 months ago #112338
by ozzyrob
Replied by ozzyrob on topic How to get an underscore in a pin/parameter name?
I'm guessing that the underscore is used as a delimiter between the hm2 and the type of board detected by the hm2_eth driver. Just a guess about the internals without going through the source code.
So depending whether you have a 7i76E, 7I80DB, 7I80HD, 7i92, 7i93 would dictate the string after the underscore.
If you work with a dash in the name with your experiments and then want to convert to real hardware a search and replace on hm2-7i76e to hm2_7i76e I would imagine working for the hal file ?
The below is from memory........
Or using a variable in the ini file maybe even simpler.
Maybe something like this
[MYBOARD]
#TYPE="hm2_7i76e"
TYPE="hm2-7i76e"
Depending on which line is uncommented would be the string that is used to replace [MYBOARD]TYPE
An example might be such as: I think is the correct sytax
setp [MYBOARD]TYPE.0.watchdog.timeout_ns 25000000
If I'm wrong on this, I'm pretty sure I've used something along these lines, I apologise and hope someone can correct this.
So depending whether you have a 7i76E, 7I80DB, 7I80HD, 7i92, 7i93 would dictate the string after the underscore.
If you work with a dash in the name with your experiments and then want to convert to real hardware a search and replace on hm2-7i76e to hm2_7i76e I would imagine working for the hal file ?
The below is from memory........
Or using a variable in the ini file maybe even simpler.
Maybe something like this
[MYBOARD]
#TYPE="hm2_7i76e"
TYPE="hm2-7i76e"
Depending on which line is uncommented would be the string that is used to replace [MYBOARD]TYPE
An example might be such as: I think is the correct sytax
setp [MYBOARD]TYPE.0.watchdog.timeout_ns 25000000
If I'm wrong on this, I'm pretty sure I've used something along these lines, I apologise and hope someone can correct this.
Last edit: 8 years 4 months ago by ozzyrob.
Please Log in or Create an account to join the conversation.
- Sparky961
- Offline
- Elite Member
-
Less
More
- Posts: 210
- Thank you received: 15
8 years 4 months ago #112339
by Sparky961
Replied by Sparky961 on topic How to get an underscore in a pin/parameter name?
Not a bad workaround, but a workaround nonetheless. I'd prefer not to have to make modifications throughout my config files. A one-line change would be acceptable.
Better would be if someone would be so kind as to provide a template component in C that does nothing except define pins. I've been trying to work with the provided "skeleton.c", but it isn't going well so far.
Better would be if someone would be so kind as to provide a template component in C that does nothing except define pins. I've been trying to work with the provided "skeleton.c", but it isn't going well so far.
Please Log in or Create an account to join the conversation.
- Sparky961
- Offline
- Elite Member
-
Less
More
- Posts: 210
- Thank you received: 15
8 years 4 months ago #112340
by Sparky961
Replied by Sparky961 on topic How to get an underscore in a pin/parameter name?
Ok, maybe my changes aren't the problem. I've copied "supply.c" to "hm2_7i76e.c", and without making any changes compile via:
It completes without complaining of error, but then when I try to load the component in HAL I get this:
............... and the dots continue forever...........
I'm built simple components using the component generator pseudo code and loaded them without problems, so why is this causing me grief?
Code:
sudo halcompile --install hm2_7i76e.c
It completes without complaining of error, but then when I try to load the component in HAL I get this:
Code:
linuxcnc@debian:~$ halrun
halcmd: loadrt hm2_7i76e
Note: Using POSIX realtime
Waiting for component 'hm2_7i76e' to become ready............
............... and the dots continue forever...........
I'm built simple components using the component generator pseudo code and loaded them without problems, so why is this causing me grief?
Please Log in or Create an account to join the conversation.
Time to create page: 1.250 seconds