Custom component - addf failed

More
08 Aug 2023 03:33 #277313 by beefy
I tried to start my Qtplasmac config from the command line but it terminated after the following 2 lines:

HAL: ERROR: function 'MY_DEMUX_6_64.0' not found
./MY_NEXTION_PENDANT.hal:27: addf failed

As I'm also wondering if I've written anything incorrectly in my hal file, lines 26 and 27 in my hal file are:

loadrt           MY_DEMUX_6_64
addf             MY_DEMUX_6_64.0         servo-thread

MY_DEMUX_6_64.comp is my custom component and I compiled it with Halcompile on my office PC.
I copied the compiled file MY_DEMUX_6_64.so and saved it to a USB stick so I could paste it into the same directory on my plasma table PC, together with all the other .so file hal components.

Is it OK to do simply that, or should I be using Halcompile on the plasma table PC and compiling my MY_DEMUX_6_64.comp file locally ??

Please Log in or Create an account to join the conversation.

More
08 Aug 2023 10:24 #277322 by tommylight
Not sure if this is the issue, but copying files to FAT32 and EXTFAT USB sticks changes file permissions, so check permissions of that file and compare to another file in that same folder.
Or, copy the component to USB and compile it on the running PC.
Or, zip the .so file and copy to usb, this usually keeps permissions.

Please Log in or Create an account to join the conversation.

More
08 Aug 2023 12:43 #277325 by gaston48
Maybe:  ?
loadrt   MY_DEMUX_6_64  count=1

Please Log in or Create an account to join the conversation.

More
08 Aug 2023 15:34 #277328 by zdenek
What's the name of your function (entry point)? Why is the ".0" there?

I personally think the loadrt syntax is very unfortunate in doing stuff behind your back. I can suspect that the idea was to "help" folks that don't know anything about software, or worse to aid a lazy programmer. The end result is that the loadrt line makes no sense, the dynamic library contains funky function names, and there is no easy way to tell what's going on.
I would really like to see this stuff cleaned up -- I noticed the problem the first time I attempted writing a custom HAL function, but didn't want to raise it until someone else struggles as I observed that cleaning stuff in LinuxCNC is not something that is done often.

Anyone interested in discussing the topic?

Please Log in or Create an account to join the conversation.

More
08 Aug 2023 17:37 - 08 Aug 2023 17:40 #277343 by chris@cnc
I'm not sure why you're so unhappy.
If you program in FUB or with Ladder you must also load and name your functions. It would not be good to load all functions in real time by default. So you choose what you need.
For understanding, i take and function.
loadrt and2 count=2  "load realtime function 2 times"
important information in my eyes.

addf and2.0 servo thread "add the function named and2.0 to the servo thread"
addf and2.1 servo thread "add the function named and2.1 to the servo thread"

they could also be named and2.spindle and and2.cyclestart. The loadrt and addf lines should then be like this
loadrt and2 names=and2.spindle,and2.cyclestart
addf and2.spindle       servo thread
addf and2.cyclestart   servo-thread
 
I think it's really cool and leaves a lot of options open.

more information is here
linuxcnc.org/docs/stable/html/hal/intro.html
linuxcnc.org/docs/stable/html/hal/basic-hal.html#_loadrt
linuxcnc.org/docs/stable/html/hal/rtcomps.html
linuxcnc.org/docs/stable/html/hal/tutorial.html
or the complete guide in the LinuxCNC Documentation, Chapter 5
file:///usr/share/doc/linuxcnc/LinuxCNC_Documentation.pdf
 
Attachments:
Last edit: 08 Aug 2023 17:40 by chris@cnc.

Please Log in or Create an account to join the conversation.

More
08 Aug 2023 17:47 #277347 by chris@cnc

I tried to start my Qtplasmac config from the command line but it terminated after the following 2 lines:


Is it OK to do simply that, or should I be using Halcompile on the plasma table PC and compiling my MY_DEMUX_6_64.comp file locally ??


Yes, it could be a problem of user rights, but it should not be a big deal to try.
sudo halcompile --install MY_DEMUX_6_64.comp

Please Log in or Create an account to join the conversation.

More
08 Aug 2023 19:38 #277370 by zdenek
@Chris I am sorry if I was not clear as to what I thought was wrong. I am not suggesting that something should be loaded automatically. I am saying that the loadrt syntax is unfortunately ambiguous and misleading. I am also quite aware that a lot of LinuxCNC old timers are comfortable with the status quo, hence my initial hesitation to raise this subject.

Please take a moment and read linuxcnc.org/docs/devel/html/hal/comp.html
while trying to put yourself in the shoes of a new user, one who may likely have been exposed to at least a bit of programming.
The document discusses a file name, component, function, and instances -- great but wait a minute, it quickly delves into introducing shortcut macros, special rules, default non-intuitive behavior etc.. By the time you will have read it the first time, you are guaranteed to not remember half of what was said.
My argument is that everything would be much easier if the syntax was a bit less cavalier, adhering to the distinctions between components, functions and instances. It may take a few extra characters to type, but it would eliminate large number of exceptions and rules in the doc above.

That said, and if I wanted to be more formal:

> For understanding, i take and function.
> loadrt and2 count=2 "load realtime function 2 times"

That, strictly speaking, is not an "and2" function. That would be an "and2" component which happens to have a file name that matches the component.

>addf and2.0 servo thread "add the function named and2.0 to the servo thread"

So here "and2" is the component, and .0 is the first instance, but what is the function name? (that's a rhetorical question Mr. Woodcock :-))

I am simply suggesting that in my opinion if all of the special rules and exceptions (e.g., HALLNAME, C name, HAL name... help me jesus) were eliminated, life would be simpler.
Cheers

Please Log in or Create an account to join the conversation.

More
08 Aug 2023 21:43 #277375 by beefy
Thanks very much for everyone's input.

I'm going back to the drawing board, and going to re-compile on the plasma table PC.

Something I'll do first though is change the name of my component, both inside the comp and the comp name itself.

Holy crap, having a closer look at the docs for writing a component and I've decided to leave underscores and dashes out of the HALNAME. 
Seems underscores are changed to dashes for instance so I'm wondering if that may be my problem.

I'm expecting things are my fault for not looking more closely at the docs for writing a component. I do have to admit I often hate looking at the docs because of the way they are written for non-beginners. Instead I often search the forums for clear cut examples of how things are done, something the docs often severely lack. I often feel like the docs are written to get rid of beginners that are not willing to devote half their life to learning Linuxcnc at a deeper level. I've done some C programming on microcontrollers and only a bit of C# on a PC and been quite successful with my projects, but when I look at the docs I'm often left thinking what the hell does that mean. It's a pity because Linuxcnc seems to be one of the more capable (Qtplasmac is just WOW) and customisable systems out there and I think we'd have a much larger following if it was easier to learn.

I'll report back with how my re-compiling goes.

Please Log in or Create an account to join the conversation.

More
09 Aug 2023 02:29 #277394 by zdenek
"I do have to admit I often hate looking at the docs because of the way they are written for non-beginners. Instead I often search the forums for clear cut examples of how things are done, something the docs often severely lack. I often feel like the docs are written to get rid of beginners that are not willing to devote half their life to learning Linuxcnc at a deeper level. I've done some C programming on microcontrollers and only a bit of C# on a PC and been quite successful with my projects, but when I look at the docs I'm often left thinking what the hell does that mean. It's a pity because Linuxcnc seems to be one of the more capable (Qtplasmac is just WOW) and customisable systems out there and I think we'd have a much larger following if it was easier to learn."

@beefy That's spot on! I, too, believe that LinuxCNC is quite powerful because it is open source and highly customizable. I would not say the doc is written to "get rid of beginners". To me it looks like it was intended to simplify people's life, but in the process it got out of hand and became too complex to carry out, in the end being what it is today. The docs just attempt to capture what has been done, which in many cases looks quite overwhelming, even for folks with software experience.
But in the end what you are saying is true; it discourages folks from reading the docs -- I am a hard-core software developer with 40+ years of writing OS-level stuff. After I read the doc, like you I decided that I was better off just following code samples rather than trying to remember all of the obscurities. Can't say I am proud of it; if you look at the components I wrote they just follow the pattern I saw working. I have the requisite skills to make it work in other ways, but I didn't think it would have been a good use of my time.

I would love to see the stuff simplified. I would like to see folks like you (with programming background) being excited about being able to create components while understanding what's being done. I recognize that we are talking machine shop crowd here, but I feel that only folks with some programming background will attempt writing components, so I don't buy the argument that dumbing down the API is helpful. As a matter of fact I'd like to suggest that simplifying the API (and the rest of the LinuxCNC ecosystem) would actually attract users.

Cheers
 

Please Log in or Create an account to join the conversation.

More
09 Aug 2023 04:38 - 09 Aug 2023 04:40 #277401 by beefy
@ zdenek

Ha ha, I'm probably over emphasizing my temporary feelings when I say the docs were meant to get rid of beginners.
What I really think is that many hard core programmers, technical people, etc, simply cannot relate to how a beginner will see something they explain. So many things are just second nature to them so they explain things as they see it. A great realisation for them may be to have a relative beginner or even those with some programming experience, proof read their docs, and when the questions follow, it will give them an insight into what's missing for others to make sense of it all.

BACK TO MY ORIGINAL ISSUE:
OK, all seems good now.
I opened up my comp file in Geany on the plasma table PC, and check all line ending were of the Unix type.
Changed the HALNAME from MY_DEMUX_6_64 to MyDemux6to64 so there was no underscores or dashes.
Likewise named the comp file to MyDemux6to64.comp.
Used Halcompile on the plasma table PC to compile the file, and it installed the compiled .so file in the modules directory with all the other hal components.
After that part of the hal file seemed to pass over without errors so I'm assuming all good there.

Qtplasmac did not completely start up but that's because of another issue in the hal file which says my ilowpass.0.in pin does not exist. Working on sorting that out now.

Thanks to everyone for the help
Last edit: 09 Aug 2023 04:40 by beefy.

Please Log in or Create an account to join the conversation.

Time to create page: 0.124 seconds
Powered by Kunena Forum