Getting error when installing a homebrew component
07 Jul 2014 21:55 - 07 Jul 2014 21:58 #48496
by ArcEye
Exactly that. When the component is polled, it is the main FUNCTION(_){ .... } that is called.
To call another function from within the FUNCTION(_), requires pushing all the existing register values, the function parameters, the base address of the call and the return address from the function onto the stack, jumping to another area of code, doing something then popping all the register values off the stack again and jumping back to the return address.
It can be quite wastefull of time and resources in rt programming, where everything needs to run as quick as possible and return.
There is ample scope for problems, if for instance the memory area used is not in unique posession of the module using it, I don't know if this caused the problems I have had with it, but I now avoid external functions.
If you have a lump of code that needs to be run several times from different stages of the function, you can set a state which runs the code and change the state to that number whenever you want it, to avoid duplication.
eg
But in your component, most of the functions are just querying the value of a bool, which could simply be done directly in the code as required.
regards
Replied by ArcEye on topic Getting error when installing a homebrew component
ArcEye:
What do you mean by moving the functions inline? Do you mean one large function that contains everything instead of the internal calls to other functions? I'll probably give that a shot.
Exactly that. When the component is polled, it is the main FUNCTION(_){ .... } that is called.
To call another function from within the FUNCTION(_), requires pushing all the existing register values, the function parameters, the base address of the call and the return address from the function onto the stack, jumping to another area of code, doing something then popping all the register values off the stack again and jumping back to the return address.
It can be quite wastefull of time and resources in rt programming, where everything needs to run as quick as possible and return.
There is ample scope for problems, if for instance the memory area used is not in unique posession of the module using it, I don't know if this caused the problems I have had with it, but I now avoid external functions.
If you have a lump of code that needs to be run several times from different stages of the function, you can set a state which runs the code and change the state to that number whenever you want it, to avoid duplication.
eg
switch(progress_level)
{
.....
case 10:
//..do stuff
progress_level = 25;
return_level = 11;
// now need to run repetitive code, so set progress_level to the level which contains it
// and set return address
return;
case 11:
// will come back here after 25
.........
case 25:
// do the repetitive function code here
progress_level = return_level;
// set to return to level 11
return;
........
}
But in your component, most of the functions are just querying the value of a bool, which could simply be done directly in the code as required.
regards
Last edit: 07 Jul 2014 21:58 by ArcEye.
The following user(s) said Thank You: Mr. Technical
Please Log in or Create an account to join the conversation.
- Mr. Technical
- Offline
- Premium Member
-
Less
More
- Posts: 80
- Thank you received: 1
15 Jul 2014 04:32 #48779
by Mr. Technical
Replied by Mr. Technical on topic Getting error when installing a homebrew component
Thanks ArcEye,
I have done that. I have some other nagging problems still remaining, but I'll start a new thread. I appreciate the help!
Mr. Technical
I have done that. I have some other nagging problems still remaining, but I'll start a new thread. I appreciate the help!
Mr. Technical
Please Log in or Create an account to join the conversation.
15 Jul 2014 13:39 #48793
by mariusl
Regards
Marius
www.bluearccnc.com
Replied by mariusl on topic Getting error when installing a homebrew component
Hi Mick
I see that you referred to userspace component rather than RT. Is there some documentation to read that will tell the difference between the two or compare them?
I see that you referred to userspace component rather than RT. Is there some documentation to read that will tell the difference between the two or compare them?
Regards
Marius
www.bluearccnc.com
Please Log in or Create an account to join the conversation.
15 Jul 2014 18:11 #48805
by ArcEye
Replied by ArcEye on topic Getting error when installing a homebrew component
Hi
I expect there are some good articles out there, I don't think there is anything specific under the Linuxcnc docs.
The major differences are memory allocation and which 'ring' the code runs in.
The big practical differences as far as components go are, the speed that the component needs to run and the resources it needs to access.
A toolchanger waiting for a single trigger pulse to get the tool 1 position say, needs to poll frequently with high kernel priority or the pulse may have passed by the next poll.
It is liable to be restricted to doing its interaction via HAL pins, which is fine for that sort of component
A serial link which updates a remote DRO will find it far more important that it can access all the standard serial libs for port access and being limited to only updating data say 4 times a second, is not really a limitation, it would take the operator longer than that to read the figure and mentally process it.
The other big plus with userspace is that you can use GUI programming libs and anything else you would do in a 'normal' program, so the options for display and processing the data are greatly increased.
The mechanics of writing a rt or userspace component using comp are probably best explored through the sources and the comp docs.
The rt component uses the FUNCTION(_) macro, that is the function which gets called each poll.
A userspace component uses the user_mainloop() function and within it the FOR_ALL_INSTS() macro (for all instances)
That is just a potted overview, hopefully start you off
regards
I expect there are some good articles out there, I don't think there is anything specific under the Linuxcnc docs.
The major differences are memory allocation and which 'ring' the code runs in.
The big practical differences as far as components go are, the speed that the component needs to run and the resources it needs to access.
A toolchanger waiting for a single trigger pulse to get the tool 1 position say, needs to poll frequently with high kernel priority or the pulse may have passed by the next poll.
It is liable to be restricted to doing its interaction via HAL pins, which is fine for that sort of component
A serial link which updates a remote DRO will find it far more important that it can access all the standard serial libs for port access and being limited to only updating data say 4 times a second, is not really a limitation, it would take the operator longer than that to read the figure and mentally process it.
The other big plus with userspace is that you can use GUI programming libs and anything else you would do in a 'normal' program, so the options for display and processing the data are greatly increased.
The mechanics of writing a rt or userspace component using comp are probably best explored through the sources and the comp docs.
The rt component uses the FUNCTION(_) macro, that is the function which gets called each poll.
A userspace component uses the user_mainloop() function and within it the FOR_ALL_INSTS() macro (for all instances)
That is just a potted overview, hopefully start you off
regards
Please Log in or Create an account to join the conversation.
15 Jul 2014 18:39 #48806
by mariusl
Regards
Marius
www.bluearccnc.com
Replied by mariusl on topic Getting error when installing a homebrew component
Good explanation, thanks man.
Regards
Marius
www.bluearccnc.com
Please Log in or Create an account to join the conversation.
Time to create page: 0.104 seconds