virtual methods in hal components ????
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 677
- Thank you received: 117
29 Jun 2023 22:37 #274475
by smc.collins
virtual methods in hal components ???? was created by smc.collins
so I have been working on my toolchanger plans, and I have a pretty deep logic flow mapped out, I am curious about the limitations of hal component C code and virtual methods before I move to my next phase of code planning.
also are there any good example of virtual methods classes etc I can look at ?
also are there any good example of virtual methods classes etc I can look at ?
Please Log in or Create an account to join the conversation.
30 Jun 2023 08:51 #274492
by rmu
Replied by rmu on topic virtual methods in hal components ????
There are no virtual methods in C.
If you need runtime polymorphism in C, what is usually done is to use function pointers in structs. Without help from macros, that quickly becomes ugly.
If you need runtime polymorphism in C, what is usually done is to use function pointers in structs. Without help from macros, that quickly becomes ugly.
Please Log in or Create an account to join the conversation.
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 677
- Thank you received: 117
30 Jun 2023 14:06 #274511
by smc.collins
Replied by smc.collins on topic virtual methods in hal components ????
I'm not a expert in c, so this is good info.
I'll look into that thanks
I'll look into that thanks
Please Log in or Create an account to join the conversation.
30 Jun 2023 14:47 #274515
by andypugh
(And, even more interestingly, I think that you can choose between hm2_spi and hm2_rpspi on the RPi according to which works better.)
All of the Hostmot2 driver is realtime code, and it is quite a good example of coding, as it has been easy to expand to support new features, functions and even hardware interfaces within the originally-designed structure.
Replied by andypugh on topic virtual methods in hal components ????
An example of this sort of thing can be seen in the Hostmot2 HAL driver where the "llio" part of the struct can point to hm2_pci, hm2_eth, hm2_spi, hm2_7i43 or hm2_7i90 low-level driver depending on the card type.If you need runtime polymorphism in C, what is usually done is to use function pointers in structs.
(And, even more interestingly, I think that you can choose between hm2_spi and hm2_rpspi on the RPi according to which works better.)
All of the Hostmot2 driver is realtime code, and it is quite a good example of coding, as it has been easy to expand to support new features, functions and even hardware interfaces within the originally-designed structure.
Please Log in or Create an account to join the conversation.
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 677
- Thank you received: 117
06 Jul 2023 16:36 #274899
by smc.collins
Replied by smc.collins on topic virtual methods in hal components ????
yeah, I'm working on the routines i want to call. breaking it into move linear, move rotary, I might integrate carousel i to it " that's conversation for another day" , and I'm working through the various mechanisms that are in common use that i can examine.
it's going to be a really complex component for sure. my first draft is going into my hurco slv40 in a few weeks, but I'm trying to make it extensible.
1 thing I'm looking for ideas about, is how to order the various subroutines in a hal file so they execute in sequence.
so there will be the various subroutines " pointers etc" and I'm looking for a way to make that configurable. i was thinking a some kind of array in the hal file the component can parse might work.
associate a move function to a number, out that in some type of data structure and have the component execute in that sequence.
I'm open to ideas here I've got a lot of the subroutines themselves written already
I'm definitely accepting code samples and links
it's going to be a really complex component for sure. my first draft is going into my hurco slv40 in a few weeks, but I'm trying to make it extensible.
1 thing I'm looking for ideas about, is how to order the various subroutines in a hal file so they execute in sequence.
so there will be the various subroutines " pointers etc" and I'm looking for a way to make that configurable. i was thinking a some kind of array in the hal file the component can parse might work.
associate a move function to a number, out that in some type of data structure and have the component execute in that sequence.
I'm open to ideas here I've got a lot of the subroutines themselves written already
I'm definitely accepting code samples and links
Please Log in or Create an account to join the conversation.
07 Jul 2023 11:13 #274935
by rmu
Replied by rmu on topic virtual methods in hal components ????
To me, it is completely unclear what you are trying to achieve, why you want to do it from a C hal component and where those "virtual methods" come into play. Such a component is probably not the best first C project.
Control of a toolchanger is probably easier done and tweaked from within G-Code or python or the soft-PLC classicalladder.
Control of a toolchanger is probably easier done and tweaked from within G-Code or python or the soft-PLC classicalladder.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 677
- Thank you received: 117
07 Jul 2023 16:20 - 07 Jul 2023 16:23 #274939
by smc.collins
Replied by smc.collins on topic virtual methods in hal components ????
tool changing with gcode is madness, and very dangerous.
I've already written a very functional tool changer program, that has error detection etc. the goal is to build a universal tool changer that can be used by anyone. programming in c isn't hard, but Linux CNC hal components have limitations . the basic premise is this, build a set of subroutines that will have a sequencer.
if you don't have anything useful to contribute, why comment?
I've already written a very functional tool changer program, that has error detection etc. the goal is to build a universal tool changer that can be used by anyone. programming in c isn't hard, but Linux CNC hal components have limitations . the basic premise is this, build a set of subroutines that will have a sequencer.
if you don't have anything useful to contribute, why comment?
Last edit: 07 Jul 2023 16:23 by smc.collins.
Please Log in or Create an account to join the conversation.
07 Jul 2023 19:44 #274953
by spumco
I am no expert here, and have exactly one fairly simple ATC (mostly) under my belt. I'm using carousel.comp & gcode to manage it, but this doesn't seem any more or less suitable than something external to a gcode solution.
Tweaking/tuning the tool change process is certainly easier using gcode (assuming no C, python, or other programming skills).
Not being snide or snarky here. Can you explain why tool changing via gcode is madness and dangerous? i.e. general principles which led you to that conclusion.
Are there conditions or machine configurations which are more or less likely to suggest that a non-gcode solution is preferred?
Does your conclusion extend to other machine accessories? - thinking bar feeders, pallet changers, part loaders... similar equipment.
Replied by spumco on topic virtual methods in hal components ????
tool changing with gcode is madness, and very dangerous.
I am no expert here, and have exactly one fairly simple ATC (mostly) under my belt. I'm using carousel.comp & gcode to manage it, but this doesn't seem any more or less suitable than something external to a gcode solution.
Tweaking/tuning the tool change process is certainly easier using gcode (assuming no C, python, or other programming skills).
Not being snide or snarky here. Can you explain why tool changing via gcode is madness and dangerous? i.e. general principles which led you to that conclusion.
Are there conditions or machine configurations which are more or less likely to suggest that a non-gcode solution is preferred?
Does your conclusion extend to other machine accessories? - thinking bar feeders, pallet changers, part loaders... similar equipment.
Please Log in or Create an account to join the conversation.
08 Jul 2023 09:04 - 08 Jul 2023 09:05 #275005
by rmu
Replied by rmu on topic virtual methods in hal components ????
If I thought my comment was useless I wouldn't have made it. My experience is also limited, I only integrated two toolchangers, a rotary one and a rack toolchanger, both with G-Code and the soft-plc. Not sure why you say that would be madness. All those move / wait / synchronisation stuff that you would need anyways is already there, it is visible, and easily adapted if the need arises.
What is madness is building a domain-language for toolchanging in a HAL-component in C. IMHO.
What is madness is building a domain-language for toolchanging in a HAL-component in C. IMHO.
Last edit: 08 Jul 2023 09:05 by rmu.
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19204
- Thank you received: 6437
08 Jul 2023 11:55 #275029
by tommylight
Replied by tommylight on topic virtual methods in hal components ????
More complications = more points of failure.
Please Log in or Create an account to join the conversation.
Time to create page: 0.086 seconds