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
The RTC Manager component interfaces with the RTC Real Time Clock (RTC) to provide time measurements.
3
+
The RTC Manager component interfaces with the Real Time Clock (RTC) to provide time measurements. When the RTC is unavailable, the component automatically fails over to monotonic time (uptime since boot) to ensure continuous system operation.
4
4
5
5
### Typical Usage
6
6
7
7
#### `TIME_SET` Command Usage
8
8
1. The component is instantiated and initialized during system startup
9
9
2. A ground station sends a `TIME_SET` command with the desired time
10
10
3. On each command, the component:
11
-
- Sets the time on the RTC
12
-
- Emits a `TimeSet` event if the time is set successfully
11
+
- Validates the time data (year >= 1900, month [1-12], day [1-31], hour [0-23], minute [0-59], second [0-59])
12
+
- Emits validation failure events if any field is invalid
13
+
- Sets the time on the RTC if validation passes
14
+
- Emits a `TimeSet` event with the previous time if the time is set successfully
13
15
- Emits a `TimeNotSet` event if the time is not set successfully
14
16
- Emits a `DeviceNotReady` event if the device is not ready
15
17
16
18
#### `timeGetPort` Port Usage
17
19
1. The component is instantiated and initialized during system startup
18
-
2. In a deployment topology, a `time connection` relation is made.
20
+
2. In a deployment topology, a `time connection` relation is made to sync FPrime's internal clock
19
21
3. On each call, the component:
20
-
-Fetches and returns the time from the RTC
21
-
-Emits a `DeviceNotReady` event if the device is not ready
22
-
23
-
#### `timeGet` Port Usage
24
-
1. The component is instantiated and initialized during system startup
25
-
2. A manager calls the `timeGet` ports
26
-
3. On each call, the component:
27
-
- Fetches and returns the time from the RTC
28
-
-Emits a `DeviceNotReady` event if the device is not ready
22
+
-Checks if the RTC device is ready
23
+
-If the RTC is ready:
24
+
- Fetches time from the RTC hardware
25
+
- Returns time with `TB_WORKSTATION_TIME` time base
26
+
- If the RTC is not ready (failover mode):
27
+
- Logs a warning message (throttled to prevent console flooding)
28
+
- Fetches monotonic uptime from the system
29
+
- Returns time with `TB_PROC_TIME` time base (uptime since boot)
30
+
-Calculates microseconds from system clock cycles for sub-second precision
29
31
30
32
## Requirements
31
33
| Name | Description | Validation |
32
34
|---|---|---|
33
35
| RtcManager-001 | The RTC Manager has a command that sets the time on the RTC | Integration test |
34
-
| RtcManager-002 | The RTC Manager has a port which, when called, set the time in FPrime| Integration test |
35
-
| RtcManager-003 |A device not ready event is emitted if the RTC is not ready | Manual|
36
-
| RtcManager-004 | A time set event is emitted if the time is set successfully | Integration test |
36
+
| RtcManager-002 | The RTC Manager has a port which, when called, returns the time from the RTC or monotonic uptime| Integration test |
37
+
| RtcManager-003 |The RTC Manager logs a warning when the RTC is not ready and falls back to monotonic time | Integration test|
38
+
| RtcManager-004 | A time set event is emitted if the time is set successfully, including the previous time| Integration test |
37
39
| RtcManager-005 | A time not set event is emitted if the time is not set successfully | Integration test |
40
+
| RtcManager-006 | The RTC Manager validates time data and emits validation failure events for invalid fields | Integration test |
41
+
| RtcManager-007 | The RTC Manager provides monotonic uptime when the RTC device is unavailable | Integration test |
42
+
| RtcManager-008 | Time increments continuously regardless of RTC availability | Integration test |
38
43
39
44
## Port Descriptions
40
45
| Name | Description |
@@ -44,14 +49,21 @@ The RTC Manager component interfaces with the RTC Real Time Clock (RTC) to provi
44
49
## Commands
45
50
| Name | Description |
46
51
|---|---|
47
-
| SET_TIME | Sets the time on the RTC |
52
+
| TIME_SET | Sets the time on the RTC with validation of all time fields |
53
+
| TEST_UNCONFIGURE_DEVICE | (Test only) Unconfigures the RTC device to test monotonic time failover |
48
54
49
55
## Events
50
56
| Name | Description |
51
57
|---|---|
52
-
| DeviceNotReady | Emits on unsuccessful device connection |
53
-
| TimeSet | Emits on successful time set |
54
-
| TimeNotSet | Emits on unsuccessful time set |
58
+
| DeviceNotReady | Emitted when the RTC device is not ready during TIME_SET command |
59
+
| TimeSet | Emitted on successful time set, includes previous time (seconds and microseconds) |
60
+
| TimeNotSet | Emitted on unsuccessful time set |
61
+
| YearValidationFailed | Emitted when provided year is invalid (should be >= 1900) |
62
+
| MonthValidationFailed | Emitted when provided month is invalid (should be [1-12]) |
63
+
| DayValidationFailed | Emitted when provided day is invalid (should be [1-31]) |
64
+
| HourValidationFailed | Emitted when provided hour is invalid (should be [0-23]) |
65
+
| MinuteValidationFailed | Emitted when provided minute is invalid (should be [0-59]) |
66
+
| SecondValidationFailed | Emitted when provided second is invalid (should be [0-59]) |
The `timeGetPort` port is called from a `time connection` in a deployment topology to sync the RTC's time with FPrime's internal clock.
94
+
The `timeGetPort` port is called from a `time connection` in a deployment topology to sync the RTC's time with FPrime's internal clock. The component automatically falls back to monotonic uptime if the RTC is unavailable.
80
95
81
-
#### Success
96
+
#### Success (RTC Available)
82
97
```mermaid
83
98
sequenceDiagram
84
99
participant Deployment Time Connection
85
100
participant RTC Manager
86
-
participant Zephyr Time API
87
-
participant RTC
88
-
Deployment Time Connection-->>RTC Manager: Call timeGetPort time port
89
-
RTC Manager->>Zephyr Time API: Read time
90
-
Zephyr Time API->>RTC: Read time
91
-
RTC->>Zephyr Time API: Return time
92
-
Zephyr Time API->>RTC Manager: Return time
93
-
RTC Manager-->>Deployment Time Connection: Return time
101
+
participant System Clock
102
+
participant Zephyr RTC API
103
+
participant RTC Sensor
104
+
Deployment Time Connection->>RTC Manager: Call timeGetPort time port
| 2025-11-14 | Added monotonic time failover when RTC unavailable, input validation for TIME_SET command, TEST_UNCONFIGURE_DEVICE test command, and console logging for device not ready conditions |
0 commit comments