2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef VEHICLE_CLIENT_INCLUDE_VEHICLE_SERVICE_VEHICLE_API_H_
18 #define VEHICLE_CLIENT_INCLUDE_VEHICLE_SERVICE_VEHICLE_API_H_
21 * @brief vehicle api header file
24 /** @addtogroup BaseSystem
27 /** @addtogroup vehicle_service
31 /** @addtogroup vehicle
32 * @ingroup vehicle_service
36 /******************************************************************************
37 * Fine name :Vehicle_API.h
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>
46 /************************************************************************
48 ************************************************************************/
49 /*----------------------------------------------------------------------*
50 * VECHILE_RET_API definition *
51 *----------------------------------------------------------------------*/
56 #define VEHICLE_RET_NORMAL 0
59 * \~english No register data ID
61 #define VEHICLE_RET_ERROR_DID (-2)
64 * \~english Input parameter error
66 #define VEHICLE_RET_ERROR_PARAM (-4)
69 * \~english Create event error
71 #define VEHICLE_RET_ERROR_CREATE_EVENT (-6)
73 /*----------------------------------------------------------------------*
74 * Vehicle sensor information delivery registration API related *
75 *----------------------------------------------------------------------*/
76 /* Delivery control */
78 * \~english Register delivery
80 #define VEHICLE_DELIVERY_REGIST 0x01
84 * \~english Stop delivery
86 #define VEHICLE_DELIVERY_STOP 0x02
89 * \~english Restart delivery
91 #define VEHICLE_DELIVERY_RESTART 0x03
94 /* Delivery opportunities */
96 * \~english Delivery timing(update)
98 #define VEHICLE_DELIVERY_TIMING_UPDATE 0x01
101 * \~english Delivery timing(change)
103 #define VEHICLE_DELIVERY_TIMING_CHANGE 0x02
105 /* Drive mode switching */
109 #define VEHICLE_DRIVE_MODE_TAB 0
112 * \~english AIAPI mode(USB)
114 #define VEHICLE_DRIVE_MODE_ATAPI 1
116 /*----------------------------------------------------------------------*
118 *----------------------------------------------------------------------*/
120 /* Since it is defined in #define the commodity code, the public CID is defined in #define */
122 * \~english Vehicle sensor information notify commandID
124 #define CID_VEHICLESENS_VEHICLE_INFO 0x00000200
126 /* Message body size(byte) */
128 * \~english Vehicle sensor information data max size
130 #define VEHICLE_VSINFO_DSIZE 80
132 /************************************************************************
133 * typedef definition *
134 ************************************************************************/
136 * \~english API return value
138 typedef int32_t VEHICLE_RET_API;
140 /************************************************************************
141 * struct definition *
142 ************************************************************************/
144 /************************************************************************
145 * TAG : VEHICLE_MSG_VSINFO_DAT
146 * ABSTRACT : Vehicle sensor information notification message(->User)
147 ************************************************************************/
148 /** \~english Vehicle sensor information notification message */
150 * \~english Vehicle sensor information notify message data
154 * \~english Vehicle sensor information data ID
159 * \~english Vehicle sensor information data size
164 * \~english Vehicle sensor information receive flag
174 * \~english Vehicle sensor information data
176 uint8_t data[VEHICLE_VSINFO_DSIZE];
177 } VEHICLE_MSG_VSINFO_DAT;
180 * \~english Vehicle sensor information notify message
184 * \~english Vehicle sensor information data struct
186 VEHICLE_MSG_VSINFO_DAT data;
187 } VEHICLE_MSG_VSINFO;
189 /************************************************************************
190 * Function prototype *
191 ************************************************************************/
195 /*[VEHICLE_API Public API]*/
196 /* Display time middle API prototype *************/
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
231 * \~english @par Type
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
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);
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
278 * \~english @par Type
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
287 int32_t Vehicle_GetVehicleData(HANDLE h_app, uint32_t ul_did, void *p_dest_data,
288 uint16_t us_dest_size);
294 /** @}*/ // end of vehicle
295 /** @}*/ // end of VehicleService
296 /** @}*/ // end of BaseSystem
298 #endif // VEHICLE_CLIENT_INCLUDE_VEHICLE_SERVICE_VEHICLE_API_H_