Resources for C++ User Space Component Authoring?
- chowderhead
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 11
29 Apr 2024 16:54 #299327
by chowderhead
Resources for C++ User Space Component Authoring? was created by chowderhead
I've been writing US components in Python, and want to test the C++ waters. Are there any resources to get me going? My C++ skills are middling...
Please Log in or Create an account to join the conversation.
- tommylight
- Online
- Moderator
Less
More
- Posts: 19011
- Thank you received: 6371
29 Apr 2024 18:51 #299332
by tommylight
Replied by tommylight on topic Resources for C++ User Space Component Authoring?
I think Rod mentioned a while back some google video about it, had a look at it, it was good so i saved it somewhere... no idea where, i'll have a look later and post back if i can find it.
Not sure if it was C++ but those are quite similar.
Not sure if it was C++ but those are quite similar.
The following user(s) said Thank You: chowderhead
Please Log in or Create an account to join the conversation.
30 Apr 2024 12:13 #299391
by rodw
Replied by rodw on topic Resources for C++ User Space Component Authoring?
One of the best ways to learn C is to read some C code.
This folder is a treasure trove of hal component examples
github.com/LinuxCNC/linuxcnc/tree/master/src/hal/components
And read these docs. linuxcnc.org/docs/stable/html/hal/comp.html
When you are ready, pick a real simple example (like and2.comp), compile it yourself, then use it for a template for your first component.
Try writing a component that lights up a pin when th X axis is > 50% of its travel or some other trivial example.
Or pretend your x axis is slightly crooked (say 3%). Compensate for this error by moving the Y axis based on X axis position.
This folder is a treasure trove of hal component examples
github.com/LinuxCNC/linuxcnc/tree/master/src/hal/components
And read these docs. linuxcnc.org/docs/stable/html/hal/comp.html
When you are ready, pick a real simple example (like and2.comp), compile it yourself, then use it for a template for your first component.
Try writing a component that lights up a pin when th X axis is > 50% of its travel or some other trivial example.
Or pretend your x axis is slightly crooked (say 3%). Compensate for this error by moving the Y axis based on X axis position.
Please Log in or Create an account to join the conversation.
- chowderhead
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 11
01 May 2024 15:57 #299471
by chowderhead
Replied by chowderhead on topic Resources for C++ User Space Component Authoring?
Thank you, Rod. I've been using halcompile for quite a while for RT components. Are you saying I can use it for compiling US components, too? Just to outline my use case:
I have homebrew sensors using udp communication over a dedicated LAN to talk with my current Python US components on the LCNC host. I've found I can significantly reduce resource consumption on the sensors (Orange Pi and Jetson Nano dev boards) by moving from Python to C++, and reason I'll see similar by doing so on the LCNC host. Since I've gained some chops building C++ for the sensors, I figured I'd leverage that to improve whole system performance. But it isn't clear to me how to do that given I have to link a bunch of libraries (opencv, socket, inet, etc.). I suppose I could dissect halcompile, but hope there might be a quicker route.
I have homebrew sensors using udp communication over a dedicated LAN to talk with my current Python US components on the LCNC host. I've found I can significantly reduce resource consumption on the sensors (Orange Pi and Jetson Nano dev boards) by moving from Python to C++, and reason I'll see similar by doing so on the LCNC host. Since I've gained some chops building C++ for the sensors, I figured I'd leverage that to improve whole system performance. But it isn't clear to me how to do that given I have to link a bunch of libraries (opencv, socket, inet, etc.). I suppose I could dissect halcompile, but hope there might be a quicker route.
Please Log in or Create an account to join the conversation.
- chowderhead
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 11
01 May 2024 17:50 - 01 May 2024 17:51 #299483
by chowderhead
Replied by chowderhead on topic Resources for C++ User Space Component Authoring?
I have, perhaps, answered my own question with a simple halcompile -h:
halcompile: Build, compile, and install LinuxCNC HAL components
Usage:
halcompile compfile...
[sudo] halcompile compfile...
halcompile --compile --userspace cfile...
[sudo] halcompile --install --userspace cfile...
[sudo] halcompile --install --userspace pyfile...
halcompile --print-modinc
Option to set maximum 'personalities' items:
--personalities=integer_value (default is 64)
Options to add compile and link flags (only for userspace, only for .c files)
--extra-compile-args="-I/usr/include/..."
--extra-link-args="-l..."
BUT, it looks like only for C, not C++?
halcompile: Build, compile, and install LinuxCNC HAL components
Usage:
halcompile compfile...
[sudo] halcompile compfile...
halcompile --compile --userspace cfile...
[sudo] halcompile --install --userspace cfile...
[sudo] halcompile --install --userspace pyfile...
halcompile --print-modinc
Option to set maximum 'personalities' items:
--personalities=integer_value (default is 64)
Options to add compile and link flags (only for userspace, only for .c files)
--extra-compile-args="-I/usr/include/..."
--extra-link-args="-l..."
BUT, it looks like only for C, not C++?
Last edit: 01 May 2024 17:51 by chowderhead.
Please Log in or Create an account to join the conversation.
- chowderhead
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 11
04 May 2024 01:00 #299680
by chowderhead
Replied by chowderhead on topic Resources for C++ User Space Component Authoring?
Got it working. The vfd files in src/hal/user_comps ended up being very helpful. Thanks for the tips, all.
Please Log in or Create an account to join the conversation.
Time to create page: 0.069 seconds