Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / stub / vehicle / client / include / stub / Vehicle_API.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef VEHICLE_CLIENT_INCLUDE_VEHICLE_SERVICE_VEHICLE_API_H_
18 #define VEHICLE_CLIENT_INCLUDE_VEHICLE_SERVICE_VEHICLE_API_H_
19 /**
20  * @file Vehicle_API.h
21  * @brief vehicle api header file
22  */
23
24 /** @addtogroup BaseSystem
25  *  @{
26  */
27 /** @addtogroup vehicle_service
28  *  @ingroup BaseSystem
29  *  @{
30  */
31 /** @addtogroup vehicle
32  *  @ingroup vehicle_service
33  *  @{
34  */
35
36 /******************************************************************************
37  * Fine name    :Vehicle_API.h
38  * System name    :GPF
39  * Subsystem name  :Vehicle I/F library
40  ******************************************************************************/
41 #include <peripheral_service/Canif_API.h>
42 #include <stub/Vehicle_Sensor_Common_API.h>
43 #include <stub/vehicle_notifications.h>
44 #include <native_service/frameworkunified_service_protocol.h>
45
46 /************************************************************************
47  *      Macro definition                          *
48  ************************************************************************/
49 /*----------------------------------------------------------------------*
50  *  VECHILE_RET_API definition                        *
51  *----------------------------------------------------------------------*/
52 /* Normal */
53 /**
54  * \~english  Sucess
55  */
56 #define  VEHICLE_RET_NORMAL        0
57
58 /**
59  * \~english  No register data ID
60  */
61 #define  VEHICLE_RET_ERROR_DID      (-2)
62
63 /**
64  * \~english  Input parameter error
65  */
66 #define  VEHICLE_RET_ERROR_PARAM      (-4)
67
68 /**
69  * \~english  Create event error
70  */
71 #define  VEHICLE_RET_ERROR_CREATE_EVENT  (-6)
72
73 /*----------------------------------------------------------------------*
74  *  Vehicle sensor information delivery registration API related        *
75  *----------------------------------------------------------------------*/
76 /* Delivery control */
77 /**
78  * \~english  Register delivery
79  */
80 #define  VEHICLE_DELIVERY_REGIST      0x01
81
82 #if 0
83 /**
84  * \~english  Stop delivery
85  */
86 #define  VEHICLE_DELIVERY_STOP    0x02
87
88 /**
89  * \~english  Restart delivery
90  */
91 #define  VEHICLE_DELIVERY_RESTART  0x03
92 #endif
93
94 /* Delivery opportunities */
95 /**
96  * \~english  Delivery timing(update)
97  */
98 #define  VEHICLE_DELIVERY_TIMING_UPDATE  0x01
99
100 /**
101  * \~english  Delivery timing(change)
102  */
103 #define  VEHICLE_DELIVERY_TIMING_CHANGE  0x02
104
105 /* Drive mode switching */
106 /**
107  * \~english  TAB mode
108  */
109 #define  VEHICLE_DRIVE_MODE_TAB    0
110
111 /**
112  * \~english  AIAPI mode(USB)
113  */
114 #define  VEHICLE_DRIVE_MODE_ATAPI  1
115
116 /*----------------------------------------------------------------------*
117  *  Message related                            *
118  *----------------------------------------------------------------------*/
119 /* Command ID */
120 /* Since it is defined in #define the commodity code, the public CID is defined in #define */
121 /**
122  * \~english  Vehicle sensor information notify commandID
123  */
124 #define  CID_VEHICLESENS_VEHICLE_INFO    0x00000200
125
126 /* Message body size(byte) */
127 /**
128  * \~english  Vehicle sensor information data max size
129  */
130 #define  VEHICLE_VSINFO_DSIZE      80
131
132 /************************************************************************
133  *      typedef definition                          *
134  ************************************************************************/
135 /**
136  * \~english  API return value
137  */
138 typedef int32_t VEHICLE_RET_API;
139
140 /************************************************************************
141  *      struct definition                          *
142  ************************************************************************/
143
144 /************************************************************************
145  * TAG       : VEHICLE_MSG_VSINFO_DAT
146  * ABSTRACT  : Vehicle sensor information notification message(->User)
147  ************************************************************************/
148 /** \~english Vehicle sensor information notification message */
149 /**
150  * \~english  Vehicle sensor information notify message data
151  */
152 typedef struct {
153   /**
154    * \~english  Vehicle sensor information data ID
155    */
156   uint32_t did;
157
158   /**
159    * \~english  Vehicle sensor information data size
160    */
161   uint16_t size;
162
163   /**
164    * \~english  Vehicle sensor information receive flag
165    */
166   uint8_t rcvFlag;
167
168   /**
169    * \~english  Reserve
170    */
171   uint8_t reserve;
172
173   /**
174    * \~english  Vehicle sensor information data
175    */
176   uint8_t data[VEHICLE_VSINFO_DSIZE];
177 } VEHICLE_MSG_VSINFO_DAT;
178
179 /**
180  * \~english  Vehicle sensor information notify message
181  */
182 typedef struct {
183   /**
184    * \~english  Vehicle sensor information data struct
185    */
186   VEHICLE_MSG_VSINFO_DAT data;
187 } VEHICLE_MSG_VSINFO;
188
189 /************************************************************************
190  *      Function prototype                        *
191  ************************************************************************/
192 #ifdef __cplusplus
193 extern "C" {
194 #endif
195 /*[VEHICLE_API Public API]*/
196 /* Display time middle API prototype *************/
197
198 /**
199  * \ingroup Vehicle_DeliveryEntry
200  * \~english @par Overview
201  *      - Register delivery of vehicle information.
202  * \~english @param [in]  h_app
203  *      HANDLE          -    The application handle of the calling thread
204  * \~english @param [in]  notify_name
205  *      PCSTR           -    Vehicle information notification destination threa name
206  * \~english @param [in]  ul_did
207  *      uint32_t        -    Vehicle Data ID
208  * \~english @param [in]  uc_ctrl_flg
209  *      uint8_t         -    Register delivery
210  * \~english @param [in]  uc_delivery_timing
211  *      uint8_t         -    Delivery timing(change/update)
212  * \~english @retval  VEHICLE_RET_NORMAL             : Success(register successful)
213  * \~english @retval  VEHICLE_RET_ERROR_CREATE_EVENT : Failure(event generation failure)
214  * \~english @retval  VEHICLE_RET_ERROR_PARAM        : Invalid parameter
215  * \~english @par Precondition
216  *      - The generation/initialization of dispatcher for application(PadCreateDispatcherWithoutLoop etc.) is done.
217  *      - The availability of the vehicle process is TRUE.
218  * \~english @par Changing internal state
219  *      - No change of internal state by this API occurs.
220  * \~english @par Processing failure condition
221  *      - Delivery control flag(uc_ctrl_flg) is not VEHICLE_DELIVERRY_REGIST [VEHICLE_RET_ERROR_PARAM]
222  *      - Delivery timing is invalid(not change/update) [VEHICLE_RET_ERROR_PARAM]
223  *      - Failed to generate a message queue handle for transmission with
224  *        the vehicle process [VEHICLE_RET_ERROR_CREATE_EVENT]
225  *      - Synchronous communication received on the vehicle process side failed to
226  *        get data [VEHICLE_RET_ERROR_CREATE_EVENT]
227  *      - The data ID does not exit in the management list on the vehicle process [VEHICLE_RET_ERROR_CREATE_EVENT]
228  *      - The number of delivery registrations has reached the max number [VEHICLE_RET_ERROR_CREATE_EVENT]
229  * \~english @par Classification
230  *      - Public
231  * \~english @par Type
232  *      - Sync
233  * \~english @par Details
234  *      - By calling this API, we request to register delivery specified vehicle information.
235  *      - It returns from this API by returning the delivery registration result by the Return value.
236  *      - The specified vehicle information is notified after delivery registration.
237  *      - Data delivery/reception is performed by asynchronous communication,
238  *        and the receiving side acquires with command"CID_VEHICLESENS_VEHICLE_INFO".
239  *      - An example in which a process using NSFW registers"CID_VEHICLESENS_VEHICLE_INFO" is shown below.
240  *      - Example) when above CID received, callback function(SampleCallBackFunc) is executed.
241  *      -   FrameworkunifiedAttachCallbackToDispatcher(hApp, TN_VEHICLE_SENS, CID_VEHICLESENS_VEHICLE_INFO, SampleCallBackFunc).
242  * \~english @see Vehicle_GetVehicleData, FrameworkunifiedMcOpenSender, FrameworkunifiedInvokeSync
243  */
244 VEHICLE_RET_API Vehicle_DeliveryEntry(HANDLE h_app, PCSTR notify_name,
245                                       uint32_t ul_did, uint8_t uc_ctrl_flg,
246                                       uint8_t uc_delivery_timing);
247
248 /**
249  * \ingroup Vehicle_GetVehicleData
250  * \~english @par Overview
251  *      - Get vehicle information data(arbitrary data).
252  * \~english @param [in]  h_app
253  *      HANDLE         -    The application handle of the calling thread
254  * \~english @param [in]  ul_did
255  *      uint32_t       -    Vehicle Data ID
256  * \~english @param [out] p_dest_data
257  *      void *         -    Data buffer
258  * \~english @param [in]  us_dest_size
259  *      uint16_t       -    Data buffer size(byte)
260  * \~english @retval  Integer(>0)                      : The stored data size
261  * \~english @retval  VEHICLE_RET_ERROR_CREATE_EVENT   : Failure(event generation failure)
262  * \~english @retval  VEHICLE_RET_ERROR_PARAM          : Invalid parameter
263  * \~english @par Precondition
264  *      - The generation/initialization of dispatcher for application(PadCreateDispatcherWithoutLoop etc.) is done.
265  *      - The availability of the vehicle process is TRUE.
266  * \~english @par Changing internal state
267  *      - No change of internal state by this API occurs.
268  * \~english @par Processing failure condition
269  *      - Failed to generate a message queue handle for transmission with
270  *        the vehicle process [VEHICLE_RET_ERROR_CREATE_EVENT]
271  *      - Input data buffer size(us_dest_size) is zero [VEHICLE_RET_ERROR_PARAM]
272  *      - Input data buffer(p_dest_data) is NULL [VEHICLE_RET_ERROR_PARAM]
273  *      - Synchronous communication received on the vehicle process side failed to
274  *        get data [VEHICLE_RET_ERROR_CREATE_EVENT]
275  *      - The data ID does not exit in the management list on the vehicle process [VEHICLE_RET_ERROR_CREATE_EVENT]
276  * \~english @par Classification
277  *      - Public
278  * \~english @par Type
279  *      - Sync
280  * \~english @par Details
281  *      - By calling this API, we obtain specified vehicle information.
282  *      - The vehicle data will be written to parameter(pDestData).
283  *      - Data delivery/reception is performed by asynchronous communication,
284  *        and the receiving side acquires with command"CID_VEHICLESENS_VEHICLE_INFO".
285  * \~english @see Vehicle_DeliveryEntry, FrameworkunifiedMcOpenSender, FrameworkunifiedInvokeSync
286  */
287 int32_t Vehicle_GetVehicleData(HANDLE h_app, uint32_t ul_did, void *p_dest_data,
288                                uint16_t us_dest_size);
289
290 #ifdef __cplusplus
291 }
292 #endif
293
294 /** @}*/  // end of vehicle
295 /** @}*/  // end of VehicleService
296 /** @}*/  // end of BaseSystem
297
298 #endif  // VEHICLE_CLIENT_INCLUDE_VEHICLE_SERVICE_VEHICLE_API_H_