le_wdog_interface.h

Go to the documentation of this file.
1 
2 
3 /*
4  * ====================== WARNING ======================
5  *
6  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
7  * DO NOT MODIFY IN ANY WAY.
8  *
9  * ====================== WARNING ======================
10  */
11 
12 /**
13  * @page c_wdog Watchdog Service
14  *
15  * @ref le_wdog_interface.h "Type/Function Reference"
16  *
17  * @section Watchdog Service
18  *
19  * Provides an API for monitoring critical applications and services for deadlocks and other
20  * similar faults. The watchdog for a process is started by calling @c le_wdog_Kick or
21  * @c le_wdog_Timeout. Once started, the watchdog must be kicked periodically by calling
22  * @c le_wdog_Kick. If the watchdog is not kicked (because it is deadlocked, for example),
23  * the watchdog service will attempt to recover the service by killing the process and
24  * executing the action specified in the process' watchdogAction (if specified)
25  * otherwise its faultAction.
26  *
27  * Generally a service which uses the watchdog should set @c watchdogTimeout to give the
28  * default timeout, and @c watchdogAction to give a recovery action.
29  *
30  * Critical services should also set @c maxWatchdogTimeout. In this case the watchdog
31  * will be started on system boot, and cannot be stopped or set
32  * longer than the timeout given in @c maxWatchdogTimeout. This ensures the service is
33  * always running as long as the system is running.
34  *
35  * @note If maxWatchdogTimeout is not set, no more action is taken if performing the process'
36  * @c watchdogAction doesn't recover the process. If @c maxWatchdogTimeout is specified the
37  * system will be rebooted if the process does not recover.
38  *
39  * Additionally the watchdog service can be configured to call a callback periodically if
40  * the watchdog service process is functioning; i.e. all watchdogs have been kicked and/or
41  * non-functioning processes are being recovered. Typically this callback will kick
42  * an external watchdog such as @c /dev/watchdog.
43  *
44  * Copyright (C) Sierra Wireless Inc.
45  */
46 /**
47  * @file le_wdog_interface.h
48  *
49  * Legato @ref c_wdog include file.
50  *
51  * Copyright (C) Sierra Wireless Inc.
52  */
53 /**
54  * Special values that have specific meaning when used as durations in Timeout():
55  * - @ref LE_WDOG_TIMEOUT_NEVER
56  * - @ref LE_WDOG_TIMEOUT_NOW
57  */
58 
59 #ifndef LE_WDOG_INTERFACE_H_INCLUDE_GUARD
60 #define LE_WDOG_INTERFACE_H_INCLUDE_GUARD
61 
62 
63 #include "legato.h"
64 
65 
66 //--------------------------------------------------------------------------------------------------
67 /**
68  * Type for handler called when a server disconnects.
69  */
70 //--------------------------------------------------------------------------------------------------
71 typedef void (*le_wdog_DisconnectHandler_t)(void *);
72 
73 //--------------------------------------------------------------------------------------------------
74 /**
75  *
76  * Connect the current client thread to the service providing this API. Block until the service is
77  * available.
78  *
79  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
80  * called before any other functions in this API. Normally, ConnectService is automatically called
81  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
82  *
83  * This function is created automatically.
84  */
85 //--------------------------------------------------------------------------------------------------
87 (
88  void
89 );
90 
91 //--------------------------------------------------------------------------------------------------
92 /**
93  *
94  * Try to connect the current client thread to the service providing this API. Return with an error
95  * if the service is not available.
96  *
97  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
98  * called before any other functions in this API. Normally, ConnectService is automatically called
99  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
100  *
101  * This function is created automatically.
102  *
103  * @return
104  * - LE_OK if the client connected successfully to the service.
105  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
106  * bound.
107  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
108  * - LE_COMM_ERROR if the Service Directory cannot be reached.
109  */
110 //--------------------------------------------------------------------------------------------------
112 (
113  void
114 );
115 
116 //--------------------------------------------------------------------------------------------------
117 /**
118  * Set handler called when server disconnection is detected.
119  *
120  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
121  * to continue without exiting, it should call longjmp() from inside the handler.
122  */
123 //--------------------------------------------------------------------------------------------------
125 (
126  le_wdog_DisconnectHandler_t disconnectHandler,
127  void *contextPtr
128 );
129 
130 //--------------------------------------------------------------------------------------------------
131 /**
132  *
133  * Disconnect the current client thread from the service providing this API.
134  *
135  * Normally, this function doesn't need to be called. After this function is called, there's no
136  * longer a connection to the service, and the functions in this API can't be used. For details, see
137  * @ref apiFilesC_client.
138  *
139  * This function is created automatically.
140  */
141 //--------------------------------------------------------------------------------------------------
143 (
144  void
145 );
146 
147 
148 //--------------------------------------------------------------------------------------------------
149 /**
150  * Suspend the watchdog so that it never times out.
151  */
152 //--------------------------------------------------------------------------------------------------
153 #define LE_WDOG_TIMEOUT_NEVER -1
154 
155 //--------------------------------------------------------------------------------------------------
156 /**
157  * Timeout immediately
158  */
159 //--------------------------------------------------------------------------------------------------
160 #define LE_WDOG_TIMEOUT_NOW 0
161 
162 //--------------------------------------------------------------------------------------------------
163 /**
164  * Reference type used by Add/Remove functions for EVENT 'le_wdog_ExternalWatchdog'
165  */
166 //--------------------------------------------------------------------------------------------------
167 typedef struct le_wdog_ExternalWatchdogHandler* le_wdog_ExternalWatchdogHandlerRef_t;
168 
169 
170 //--------------------------------------------------------------------------------------------------
171 /**
172  * External watchdog kick handler
173  */
174 //--------------------------------------------------------------------------------------------------
176 (
177  void* contextPtr
178  ///<
179 );
180 
181 //--------------------------------------------------------------------------------------------------
182 /**
183  * Kicks the watchdog timer.
184  *
185  * Once the watchdog has been kicked it must be kicked again before the expiration of the current
186  * effective timeout else the configured WatchdogAction will be executed.
187  */
188 //--------------------------------------------------------------------------------------------------
189 void le_wdog_Kick
190 (
191  void
192 );
193 
194 //--------------------------------------------------------------------------------------------------
195 /**
196  * Set a time out.
197  *
198  * The watchdog is kicked and a new effective timeout value is set. The new timeout will be
199  * effective until the next kick at which point it will revert to the original value.
200  */
201 //--------------------------------------------------------------------------------------------------
202 void le_wdog_Timeout
203 (
204  int32_t milliseconds
205  ///< [IN] The number of milliseconds until this timer expires
206 );
207 
208 //--------------------------------------------------------------------------------------------------
209 /**
210  * Add handler function for EVENT 'le_wdog_ExternalWatchdog'
211  *
212  * Register an external watchdog kick handler.
213  *
214  * Register an handler which will be triggered periodically if all monitored apps are alive.
215  */
216 //--------------------------------------------------------------------------------------------------
218 (
219  int32_t milliseconds,
220  ///< [IN] The period to kick external watchdog
222  ///< [IN] The handler for external watchdog kicks
223  void* contextPtr
224  ///< [IN]
225 );
226 
227 //--------------------------------------------------------------------------------------------------
228 /**
229  * Remove handler function for EVENT 'le_wdog_ExternalWatchdog'
230  */
231 //--------------------------------------------------------------------------------------------------
233 (
235  ///< [IN]
236 );
237 
238 #endif // LE_WDOG_INTERFACE_H_INCLUDE_GUARD
le_result_t
Definition: le_basics.h:35
void(* le_wdog_ExternalWatchdogHandlerFunc_t)(void *contextPtr)
Definition: le_wdog_interface.h:176
le_wdog_ExternalWatchdogHandlerRef_t le_wdog_AddExternalWatchdogHandler(int32_t milliseconds, le_wdog_ExternalWatchdogHandlerFunc_t handlerPtr, void *contextPtr)
struct le_wdog_ExternalWatchdogHandler * le_wdog_ExternalWatchdogHandlerRef_t
Definition: le_wdog_interface.h:167
void le_wdog_RemoveExternalWatchdogHandler(le_wdog_ExternalWatchdogHandlerRef_t handlerRef)
void(* le_wdog_DisconnectHandler_t)(void *)
Definition: le_wdog_interface.h:71
void le_wdog_Kick(void)
le_result_t le_wdog_TryConnectService(void)
void le_wdog_Timeout(int32_t milliseconds)
void le_wdog_DisconnectService(void)
void le_wdog_ConnectService(void)
void le_wdog_SetServerDisconnectHandler(le_wdog_DisconnectHandler_t disconnectHandler, void *contextPtr)