HAL RT module problem

More
11 Jan 2023 17:52 #261598 by Dave3891
I am having an issue with loading 2 custom components at the same time.
If I run them individually they work perfectly, but when I load both they stop running. Both are similar and use the same cpp trajectory generator files, but are named/pinned differently.

Basic testing is to create a thread, load the first module, addf it and start. I have a debug print that I can see printing but as soon as I loadrt the second module it kills the running of the first but no error message is shown.
This will also happen if I load the second one first and then the first module.

Not sure if they have some similar symbol exported that the hal is trying to call? Is there something I should be looking for with debugging this?

Any help would be appreciated.
 

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

More
12 Jan 2023 12:59 #261690 by andypugh
Replied by andypugh on topic HAL RT module problem
halcmd show funct

Would tell you if there is a function name clash.

I am a bit confused by the combination of "cpp" and "HAL RT". I thought that realtime comps had to be written in plain C.

What happens if you loadrt and addf both components before starting the thread?

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

More
12 Jan 2023 16:44 #261710 by Dave3891
Replied by Dave3891 on topic HAL RT module problem
HAL show funct outputs this with both loaded
Exported Functions:
Owner CodeAddr Arg FP Users Name
00009 7f85bd08e730 7f85bd0d44a8 NO 1 fanuc100
00022 7f85bc39b366 7f85bd0d44a8 NO 0 orbitweld

Not sure if both have the same Arg is a problem?

The main part of the component is written in C and is uses a wrapper to interface with CPP libraries (Ruckig and KDL)

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

More
12 Jan 2023 17:17 #261719 by andypugh
Replied by andypugh on topic HAL RT module problem
Are the CPP libraries realtime-safe? They need to be non-blocking and thread-safe if they are called from the realtime thread.
Is it possible that non-atomic memory access in one function is crashing the other?
What happens if you comment-out the c++ calls in one of the functions?

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

More
12 Jan 2023 17:27 #261721 by Dave3891
Replied by Dave3891 on topic HAL RT module problem
I believe they are realtime safe, they are both designed for robotic control (one is kinematics and the other is trajectory) and made to be called in a servo loop style system.

I have stripped one down as far as commenting out all the calls in the function that is called by hal_export_funct so it shouldn't be doing anything but it still stalls the system. I don't know if there is some compiler flag or other problem I am missing?

I don't suppose there is any way to use breakpoints with these components? Or any debugging tools?

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

More
12 Jan 2023 22:03 #261745 by Dave3891
Replied by Dave3891 on topic HAL RT module problem
I finally got an error while trying to load this time

Note: Using POSIX non-realtime
HAL: ERROR: pin_new(hal_trajectory.enable) called with already-initialized memory
HAL: ERROR: data_ptr_addr not in shared memory
HAL: ERROR: pin_new(hal_trajectory.max_acceleration) called with already-initialized memory
HAL: ERROR: pin_new(hal_trajectory.tcp_velocity) called with already-initialized memory
orbittest.hal:3: waitpid failed /home/ael/linuxcnc-dev2/bin/rtapi_app hal_trajectory
orbittest.hal:3: /home/ael/linuxcnc-dev2/bin/rtapi_app exited without becoming ready
orbittest.hal:3: insmod for hal_trajectory failed, returned -1

Some kind of memory conflict

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

More
13 Jan 2023 01:09 #261763 by andypugh
Replied by andypugh on topic HAL RT module problem

Note: Using POSIX non-realtime


You are not using a realtime kernel, but that probably isn't the problem.

HAL: ERROR: pin_new(hal_trajectory.enable) called with already-initialized memory
HAL: ERROR: data_ptr_addr not in shared memory



How odd.

forum.linuxcnc.org/27-driver-boards/3437...cks-up-and-wont-load has the same problem, but no clear solution.
www.forum.linuxcnc.org/18-computer/39037...-allwincnc?start=150 has no obvious solution either, but seems to be creating two hal pins with the same name. (but that won't be your problem as the component names will be different for you)
github.com/LinuxCNC/linuxcnc/issues/1705 also points at duplicate pin names.

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

More
16 Jan 2023 22:24 #262178 by andypugh
Replied by andypugh on topic HAL RT module problem

I don't suppose there is any way to use breakpoints with these components? Or any debugging tools?

Debugging kernel modules is pretty much impossible as breakpointing the module halts the kernel. 
But, if you are using uspace (and you probably are) then it can probably be done. 

wiki.linuxcnc.org/cgi-bin/wiki.pl?DebuggingRtapi

I tend to always be using RTAI so this doesn't work for me, I tend to put in a bunch of rtapi_print() statements until I can fugure out what is going on. 
 

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

More
16 Jan 2023 22:48 #262181 by Dave3891
Replied by Dave3891 on topic HAL RT module problem
Thanks, I will take a look.
I did try with some rtapi print statements, but it seems to crash right in the beginning load so nothing gets output.

For now I am just building everything in a single HAL component so I can get going on testing the robot arm.

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

Time to create page: 0.117 seconds
Powered by Kunena Forum