You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another method is using the Synaptic package manager, from the Applications menu, to install the `linuxcnc-dev` or `linuxcnc-uspace-dev` packages.
56
56
57
+
58
+
== Compiling
59
+
60
+
=== Inside the source tree
61
+
62
+
Place the `.comp` file in the source directory `linuxcnc/src/hal/components` and re-run `make`.
63
+
'Comp' files are automatically detected by the build system.
64
+
65
+
If a `.comp` file is a driver for hardware, it may be placed in `linuxcnc/src/hal/drivers`
66
+
and will be built unless LinuxCNC is configured as a non-realtime simulator.
67
+
68
+
=== Realtime components outside the source tree
69
+
70
+
'halcompile' can process, compile, and install a realtime component in a single step,
71
+
placing `rtexample.ko` in the LinuxCNC realtime module directory:
72
+
73
+
----
74
+
[sudo] halcompile --install rtexample.comp
75
+
----
76
+
77
+
[NOTE]
78
+
sudo (for root permission) is needed when using LinuxCNC from a deb package install.
79
+
When using a Run-In-Place (RIP) build, root privileges should not be needed.
80
+
81
+
Or, it can process and compile in one step, leaving `example.ko` (or `example.so` for the simulator) in the current directory:
82
+
83
+
----
84
+
halcompile --compile rtexample.comp
85
+
----
86
+
87
+
Or it can simply process, leaving `example.c` in the current directory:
88
+
89
+
----
90
+
halcompile rtexample.comp
91
+
----
92
+
93
+
'halcompile' can also compile and install a component written in C, using the `--install` and `--compile` options shown above:
94
+
95
+
----
96
+
[sudo] halcompile --install rtexample2.c
97
+
----
98
+
99
+
man-format documentation can also be created from the information in the declaration section:
100
+
101
+
----
102
+
halcompile --document -o example.9 rtexample.comp
103
+
----
104
+
105
+
The resulting manpage, 'example.9' can be viewed with
106
+
107
+
----
108
+
man ./example.9
109
+
----
110
+
111
+
or copied to a standard location for manual pages.
112
+
113
+
=== Non-realtime components outside the source tree
114
+
115
+
'halcompile' can process, compile, install, and document non-realtime components:
116
+
117
+
----
118
+
halcompile non-rt-example.comp
119
+
halcompile --compile non-rt-example.comp
120
+
[sudo] halcompile --install non-rt-example.comp
121
+
halcompile --document non-rt-example.comp
122
+
----
123
+
124
+
For some libraries (for example modbus) it might be necessary to add extra compiler and linker arguments to enable the compiler to find and link the libraries.
125
+
In the case of .comp files this can be done via "option" statements in the `.comp` file.
126
+
For `.c` files this is not possible so the `--extra-compile-args` and `--extra-link-args` parameters can be used instead.
127
+
As an example, this command line can be used to compile the `vfdb_vfd.c` component out-of-tree.
NOTE: The effect of using both command-line and in-file extra-args is undefined.
132
+
57
133
== Using a Component
58
134
59
135
Components need to be loaded and added to a thread before it can be employed.
@@ -67,21 +143,21 @@ loadrt ddt
67
143
addf ddt.0 servo-thread
68
144
----
69
145
70
-
More information on 'loadrt' and 'addf' can be found in the
146
+
More information on `loadrt` and `addf` can be found in the
71
147
<<cha:basic-hal-reference,HAL Basics>>.
72
148
73
149
To test your component you can follow the examples in the <<cha:hal-tutorial,HAL Tutorial>>.
74
150
75
151
== Definitions
76
152
77
-
* 'component' - A component is a single real-time module, which is loaded with 'halcmd loadrt'.
78
-
One '.comp' file specifies one component. The component name and file name must match.
153
+
* *component* - A component is a single real-time module, which is loaded with `Halcmd loadrt`.
154
+
One `.comp` file specifies one component. The component name and file name must match.
79
155
80
-
* 'instance' - A component can have zero or more instances.
156
+
* *instance* - A component can have zero or more instances.
81
157
Each instance of a component is created equal (they all have the same pins, parameters,
82
158
functions, and data) but behave independently when their pins, parameters, and data have different values.
83
159
84
-
* 'singleton' - It is possible for a component to be a "singleton", in which case exactly one instance is created.
160
+
* *singleton* - It is possible for a component to be a "singleton", in which case exactly one instance is created.
85
161
It seldom makes sense to write a 'singleton' component, unless there can literally only be a single object of that kind in the system
86
162
(for instance, a component whose purpose is to provide a pin with the current UNIX time, or a hardware driver for the internal PC speaker).
87
163
@@ -101,7 +177,7 @@ This can be useful in components that need the timing information.
101
177
102
178
== Syntax
103
179
104
-
A '.comp' file consists of a number of declarations, followed by ';;' on a line of its own, followed by C code implementing the module's functions.
180
+
A `.comp` file consists of a number of declarations, followed by `;;` on a line of its own, followed by C code implementing the module's functions.
105
181
106
182
Declarations include:
107
183
@@ -381,8 +457,8 @@ When the item is a conditional item, it is only legal to refer to it when its 'c
381
457
382
458
== Components with one function
383
459
384
-
If a component has only one function and the string "FUNCTION" does not appear anywhere after ';;',
385
-
then the portion after ';;' is all taken to be the body of the component's single function.
460
+
If a component has only one function and the string `"FUNCTION"` does not appear anywhere after `;;`,
461
+
then the portion after `;;` is all taken to be the body of the component's single function.
386
462
See the <<code:simple-comp-example,Simple Comp>> for an example of this.
387
463
388
464
== Component Personality
@@ -417,79 +493,6 @@ If the requested number of instances exceeds the number of allowed personalities
417
493
personalities are assigned by indexing modulo the number of allowed personalities.
418
494
A message is printed denoting such assignments.
419
495
420
-
== Compiling
421
-
422
-
Place the '.comp' file in the source directory 'linuxcnc/src/hal/components' and re-run 'make'.
423
-
'Comp' files are automatically detected by the build system.
424
-
425
-
If a '.comp' file is a driver for hardware, it may be placed in 'linuxcnc/src/hal/drivers'
426
-
and will be built unless LinuxCNC is configured as a non-realtime simulator.
427
-
428
-
== Compiling realtime components outside the source tree
429
-
430
-
'halcompile' can process, compile, and install a realtime component in a single step,
431
-
placing 'rtexample.ko' in the LinuxCNC realtime module directory:
432
-
433
-
----
434
-
[sudo] halcompile --install rtexample.comp
435
-
----
436
-
437
-
[NOTE]
438
-
sudo (for root permission) is needed when using LinuxCNC from a deb package install.
439
-
When using a Run-In-Place (RIP) build, root privileges should not be needed.
440
-
441
-
Or, it can process and compile in one step, leaving 'example.ko' (or 'example.so' for the simulator) in the current directory:
442
-
443
-
----
444
-
halcompile --compile rtexample.comp
445
-
----
446
-
447
-
Or it can simply process, leaving 'example.c' in the current directory:
448
-
449
-
----
450
-
halcompile rtexample.comp
451
-
----
452
-
453
-
'halcompile' can also compile and install a component written in C, using the '--install' and '--compile' options shown above:
454
-
455
-
----
456
-
[sudo] halcompile --install rtexample2.c
457
-
----
458
-
459
-
man-format documentation can also be created from the information in the declaration section:
460
-
461
-
----
462
-
halcompile --document rtexample.comp
463
-
----
464
-
465
-
The resulting manpage, 'example.9' can be viewed with
466
-
467
-
----
468
-
man ./example.9
469
-
----
470
-
471
-
or copied to a standard location for manual pages.
472
-
473
-
== Compiling non-realtime components outside the source tree
474
-
475
-
'halcompile' can process, compile, install, and document non-realtime components:
476
-
477
-
----
478
-
halcompile non-rt-example.comp
479
-
halcompile --compile non-rt-example.comp
480
-
[sudo] halcompile --install non-rt-example.comp
481
-
halcompile --document non-rt-example.comp
482
-
----
483
-
484
-
For some libraries (for example modbus) it might be necessary to add extra compiler and linker arguments to enable the compiler to find and link the libraries.
485
-
In the case of .comp files this can be done via "option" statements in the .comp file.
486
-
For .c files this is not possible so the --extra-compile-args and --extra-link-args parameters can be used instead.
487
-
As an example, this command line can be used to compile the vfdb_vfd.c component out-of-tree.
0 commit comments