|
1 | | -The module **libmodule_posix_timer.so** is used to generate deterministic triggers for other modules. |
| 1 | +# module_posix_timer |
2 | 2 |
|
3 | | -# Functional principle |
| 3 | +[](https://github.com/robotkernel-hal/module_posix_timer/actions/workflows/build-deb.yaml) |
| 4 | +[](LICENSE) |
| 5 | +[](#) |
| 6 | +[](#) |
| 7 | +[](#) |
4 | 8 |
|
5 | | -The posix timer module supports three different modes. |
| 9 | +**Robotkernel handler module for POSIX timer integration** |
6 | 10 |
|
7 | | -## Modes |
| 11 | +`module_posix_timer` provides a high‑priority timing mechanism based on POSIX timers for the robotkernel HAL. It abstracts timer setup and notification logic to deliver accurate periodic triggers within the robotkernel execution cycle. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## ✨ Features |
| 16 | + |
| 17 | +- High‑resolution periodic timer |
| 18 | +- Real‑time safe execution |
| 19 | +- Integrates seamlessly with robotkernel event loop |
| 20 | +- Adjustable timer frequency at runtime |
| 21 | +- Optional callback hooks for custom application logic |
8 | 22 |
|
9 | 23 | Three different modes are supported by **module_posix_timer**. |
10 | 24 |
|
11 | 25 | * ***nanosleep :*** In this mode the **module_posix_timer** main thread just does a nanosleep until the period time has been elapsed. If the nanosleep call was interrupted by some signal it will sleep until the calculated period end time has been reached. This mode is easy and efficient as well. The **module_posix_timer*** thread should run at a very high priority to ensure, that it will be waken up when it's necessary. |
12 | 26 | * ***posix_timer :*** This mode creates a timer with timer_create. It configures the timer and connects it to the given signal number from the configuration string. |
13 | 27 | * ***busywait :*** In busywait the timer threads does active wait on the cpu and consumes all cpu time. This can cause higher power consumption and higher temperature (But on a PREEMPT-RT system that should not matter). |
14 | 28 |
|
15 | | -## Example config file |
| 29 | +--- |
| 30 | + |
| 31 | +## 🧩 Configuration |
| 32 | + |
| 33 | +Use the following snippet in your Robotkernel handler configuration: |
| 34 | + |
| 35 | +`main.rkc` |
| 36 | +```yaml |
| 37 | +name: posix_timer |
| 38 | +so_file: libmodule_posix_timer.so |
| 39 | +config: !include timer_0.rkc |
| 40 | +``` |
16 | 41 |
|
17 | 42 | This example config file can be used as a template for own configurations. |
18 | 43 |
|
| 44 | +`timer_0.rkc` |
19 | 45 | ```yaml |
20 | 46 | # Configuration file for module_posix_timer. |
21 | 47 | # |
@@ -57,19 +83,91 @@ timers: |
57 | 83 | # "strict" - skip all ticks which ly in the past. |
58 | 84 | #skip_missed: none |
59 | 85 | ``` |
| 86 | +| Parameter | Description | |
| 87 | +|-------------------|-------------| |
| 88 | +| `interval_sec` | Whole seconds interval between timer triggers | |
| 89 | +| `interval_nsec` | Nanoseconds interval (0–999,999,999) | |
| 90 | +| `use_eventfd` | If `true` uses `eventfd`; otherwise signal-based notifications | |
| 91 | +| `dependencies` | Other required modules (e.g. `ecat` for synchronized looping) | |
| 92 | + |
| 93 | +--- |
60 | 94 |
|
61 | | -## Trigger device |
| 95 | +## ⚙️ Runtime Behavior |
| 96 | + |
| 97 | +- Timer initialized during module startup |
| 98 | +- On each timer expiry: |
| 99 | + - Emits a HAL event or counter signal |
| 100 | + - Invokes optional callbacks for downstream modules |
| 101 | +- Supports dynamic interval adjustment at runtime |
62 | 102 |
|
63 | 103 | This module registers a trigger device for each timer to robotkernel with the following naming schemeː |
64 | 104 |
|
65 | 105 | ``` |
66 | 106 | <module_name>.<timer_name>.trigger |
67 | 107 | ``` |
68 | 108 |
|
69 | | -## Process data device |
70 | | - |
71 | 109 | The module also provides a cyclic process. It contains the actual timer interval. |
72 | 110 |
|
73 | 111 | ``` |
74 | 112 | <module_name>.<timer_name>.inputs.pd |
75 | 113 | ``` |
| 114 | +
|
| 115 | +--- |
| 116 | +
|
| 117 | +## 🖼️ Architecture Diagram |
| 118 | +
|
| 119 | +```text |
| 120 | ++-------------------+ +----------------------------+ |
| 121 | +| Robotkernel-5 |<--------->| module_posix_timer.so | |
| 122 | ++-------------------+ +-------------+--------------+ |
| 123 | + | |
| 124 | + +---------v---------+ |
| 125 | + | POSIX Timer API | |
| 126 | + | (timer_create) | |
| 127 | + +-------------------+ |
| 128 | +``` |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +## 📦 Build & Installation |
| 133 | + |
| 134 | +```bash |
| 135 | +git clone https://github.com/robotkernel-hal/module_posix_timer.git |
| 136 | +cd module_posix_timer |
| 137 | +mkdir build && cd build |
| 138 | +cmake .. |
| 139 | +make |
| 140 | +sudo make install |
| 141 | +``` |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +## 🧪 Testing |
| 146 | + |
| 147 | +```bash |
| 148 | +TODO |
| 149 | +``` |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +## 🤝 Contributing |
| 154 | + |
| 155 | +Contributions, pull requests, and issue reports are welcome. Please: |
| 156 | + |
| 157 | +- Keep builds warning-free |
| 158 | +- Stick to robotkernel style rules |
| 159 | +- Add tests for new features or regressions |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## 📄 License |
| 164 | + |
| 165 | +Distributed under the **LGPL-V3 License**. Refer to the [LICENSE](LICENSE) file for details. |
| 166 | + |
| 167 | +--- |
| 168 | + |
| 169 | +**Robotkernel HAL Project** – Real-time robotics infrastructure powered by modular, modern C++ |
| 170 | + |
| 171 | + |
| 172 | +## Example config file |
| 173 | + |
0 commit comments