Skip to main content

dpdu_api_types/
functions.rs

1use std::ffi::c_void;
2
3use crate::*;
4
5/// Constructs and initializes the PDU API library
6///
7/// ## Parameters
8/// * option_str - A list of attributes and values specific to D-PDU API
9/// * p_api_tag - Application defined tag value for callbacks
10pub type PduConstructFn =
11    extern "system" fn(option_str: *mut u8, p_api_tag: *mut c_void) -> PduError;
12
13/// Closes all open communication channels and destructs the PDU API library
14pub type PduDestructFn = extern "system" fn() -> PduError;
15
16/// Performs generic IOCTL calls on a MVCI or ComLogicalLink
17///
18/// ## Parameters
19/// * h_mod - Handle of MVCI module
20/// * h_cll - Handle of the ComLogicalLink
21/// * ioctl_commanded_id - IO Command to send to ComLogicalLink
22/// * p_input_data - Pointer to input data item (Null if not required)
23/// * p_output_data - Pointer to output data item (Null if not required)
24///
25pub type PduIoctlFn = extern "system" fn(
26    h_mod: u32,
27    h_cll: u32,
28    ioctl_commanded_id: u32,
29    p_input_data: *mut PduDataItem,
30    p_output_data: *mut *mut PduDataItem,
31) -> PduError;
32
33/// Gets version information from MVCI module
34///
35/// ## Parameters
36/// * h_mod - Handle of the MVCI module
37/// * p_version_data - Output pointer for the destination of the version data
38pub type PduGetVersionFn =
39    extern "system" fn(h_mod: u32, p_version_data: *mut VersionData) -> PduError;
40
41/// Gets runtime information from either a MVCI module, ComLogicalLink or ComPrimitive
42///
43/// ## Parameters
44/// * h_mod - Handle of the MVCI module
45/// * h_cll - Handle of the ComLogicalLink
46/// * h_cop - Handle of the ComPrimitive
47/// * p_status_code - Pointer to store the status code
48/// * p_timestamp - Pointer to store timestamp in microseconds
49/// * p_extra_info - Pointer for storing any extra information
50pub type PduGetStatusFn = extern "system" fn(
51    h_mod: u32,
52    h_cll: u32,
53    h_cop: u32,
54    p_status_code: *mut PduStatus,
55    p_timestamp: *mut u32,
56    p_extra_info: *mut u32,
57) -> PduError;
58
59/// Gets the last runtime error from the MVCI module or ComLogicalLink
60/// Used for SAE J2534-2 support
61///
62/// ## Parameters
63/// * h_mod - Handle of the MVCI module
64/// * h_cll - Handle of the ComLogicalLink
65/// * p_error_code - Pointer to store the error code
66/// * ph_cop - If the last error persists to a ComPrimitive, then this will contain the handle of the ComPrimitive
67/// * p_timestamp - Pointer to store timestamp
68/// * Pointer for storing any extra information
69pub type PduGetLastErrorFn = extern "system" fn(
70    h_mod: u32,
71    h_cll: u32,
72    p_error_code: *mut PduErrorEvt,
73    ph_cop: *mut u32,
74    p_timestamp: *mut u32,
75    p_extra_error_info: *mut u32,
76) -> PduError;
77
78/// Obtains resource status information from the PDU API
79///
80/// ## Parameters
81/// * p_resource_status - Pointer to store the status of the requested resource IDs
82pub type PduGetResourceStatusFn =
83    extern "system" fn(p_resource_status: *mut RscStatusItem) -> PduError;
84
85/// Creates a ComLogicalLink for a given resource ID
86///
87/// ## Parameters
88/// * h_mod - Handle of the MVCI module
89/// * p_rsc_data - Pointer to resource data objects
90/// * resource_id - Resource ID
91/// * p_cll_tag - Application defined tag value
92/// * ph_cll - Pointer for storing the ComLogicalLink handle to
93/// * p_cll_Create_flag - Pointer for storage of flag bits
94pub type PduCreateComLogicalLinkFn = extern "system" fn(
95    h_mod: u32,
96    p_rsc_data: *mut RscData,
97    resource_id: u32,
98    p_cll_tag: *mut c_void,
99    ph_cll: *mut u32,
100    p_cll_create_flag: *mut FlagData,
101) -> PduError;
102
103/// Destroys a given ComLogicalLink
104///
105/// ## Parameters
106/// * h_mod - Handle of the MVCI module
107/// * h_cll - Handle of the ComLogicalLink to destroy
108pub type PduDestroyComLogicalLinkFn = extern "system" fn(h_mod: u32, h_cll: u32) -> PduError;
109
110/// Connects a ComLogicalLink to a vehicle interface
111///
112/// ## Parameters
113/// * h_mod - Handle of the MVCI module
114/// * h_cll - Handle of the ComLogicalLink to connect
115pub type PduConnectFn = extern "system" fn(h_mod: u32, h_cll: u32) -> PduError;
116
117/// Disconnects a ComLogicalLink from a vehicle interface
118///
119/// ## Parameters
120/// * h_mod - Handle of the MVCI module
121/// * h_cll - Handle of the ComLogicalLink to disconnect
122pub type PduDisconnectFn = extern "system" fn(h_mod: u32, h_cll: u32) -> PduError;
123
124/// Locks a physical resource so that a ComLogicalLink has exclusive access to it
125///
126/// ## Parameters
127/// * h_mod - Handle of the MVCI module
128/// * h_cll - Handle of the ComLogicalLink to be granted exclusive access
129/// * lock_mask - Bit encoded mask to request for locking
130pub type PduLockResourceFn = extern "system" fn(h_mod: u32, h_cll: u32, lock_mask: u32) -> PduError;
131
132/// Unlocks a physical resource from a ComLogicalLink that has exclusive access to it
133///
134/// ## Parameters
135/// * h_mod - Handle of the MVCI module
136/// * h_cll - Handle of the ComLogicalLink to unlock the resource from
137/// * lock_mask - Bit encoded mask to request for release
138pub type PduUnlockResourceFn =
139    extern "system" fn(h_mod: u32, h_cll: u32, lock_mask: u32) -> PduError;
140
141/// Obtains a communication or bus ComParam out of the MVCIs working buffer of a ComLogicalLink
142///
143/// ## Parameters
144/// * h_mod - Handle of the MVCI module
145/// * h_cll - Handle of the ComLogicalLink
146/// * param_id - ID value of the ComParam that is being requested
147/// * p_param_item - Pointer to store the requested ComParam into
148pub type PduGetComParamFn = extern "system" fn(
149    h_mod: u32,
150    h_cll: u32,
151    param_id: u32,
152    p_param_item: *mut *mut ParamItem,
153) -> PduError;
154
155/// Sets a com param on a ComLogicalLink
156///
157/// ## Parameters
158/// * h_mod - Handle of the MVCI module
159/// * h_cll - Handle of the ComLogicalLink to set the param on
160/// * p_param_item - Pointer to a ComParams to set
161pub type PduSetComParamFn =
162    extern "system" fn(h_mod: u32, h_cll: u32, p_param_item: *mut ParamItem) -> PduError;
163
164/// Creates and starts a ComPrimitive
165///
166/// ## Parameters
167/// * h_mod - Handle of the MVCI module
168/// * h_cll - Handle of the ComLogicalLink to start the ComPrimitive on
169/// * cop_type - Type of ComPrimitive to start
170/// * cop_data_size - Size of the data for the ComPrimitive
171/// * p_cop_data - Pointer to data for the ComPrimitive
172/// * p_cop_tag - Application specific tag
173/// * ph_cop - Reference for storing the returned ComPrimitive handle
174pub type PduStartComPrimitiveFn = extern "system" fn(
175    h_mod: u32,
176    h_cll: u32,
177    cop_type: PduCopt,
178    cop_data_size: u32,
179    p_cop_data: *mut u8,
180    p_cop_ctrl_data: *mut CopCtrlData,
181    p_cop_tag: *mut c_void,
182    ph_cop: *mut u32,
183) -> PduError;
184
185/// Cancels and stops a ComPrimitive
186///
187/// ## Parameters
188/// * h_mod - Handle of the MVCI module
189/// * h_cll - Handle of the ComLogicalLink
190/// * h_cop - Handle of the ComPrimitive
191pub type PduCancelComPrimitiveFn =
192    extern "system" fn(h_mod: u32, h_cll: u32, h_cop: u32) -> PduError;
193
194/// Retrieves event data for a given event source
195///
196/// ## Parameter
197/// * h_mod - Handle of the MVCI module
198/// * h_cll - Handle of the ComLogicalLink
199/// * p_event_item - Pointer to store the event item
200pub type PduGetEventItemFn =
201    extern "system" fn(h_mod: u32, h_cll: u32, p_event_item: *mut *mut EventItem) -> PduError;
202
203/// Destroys a given item
204///
205/// ## Parameters
206/// * p_item - Pointer to item to be destroyed
207pub type PduDestroyItemFn = extern "system" fn(p_item: *mut PduItem) -> PduError;
208
209/// Registers a callback function
210///
211/// ## Parameters
212/// * h_mod - Handle of the MVCI module
213/// * h_cll - Handle of the ComLogicalLink
214/// * callback_fn - Callback function (null to deregister callback)
215pub type PduRegisterCallbackFn =
216    extern "system" fn(h_mod: u32, h_cll: u32, callback_fn: EventCallbackFn) -> PduError;
217
218/// Gets the Item ID of a given item
219///
220/// ## Parameters
221/// * pdu_object_type - Type of object
222/// * p_short_name - Short name of the object
223/// * p_pdu_object_id - Reference to store the object ID
224pub type PduGetObjectIdFn = extern "system" fn(
225    pdu_object_type: PduObjt,
226    p_short_name: *mut u8,
227    p_pdu_object_id: *mut u32,
228) -> PduError;
229
230/// Object module information
231///
232/// ## Parameters
233/// * p_module_id_list - Pointer for storing the pointer of the module information list
234pub type PduGetModuleIdsFn = extern "system" fn(p_module_id_list: *mut *mut ModuleItem) -> PduError;
235
236/// Get a list of resource IDs
237///
238/// ## Parameters
239/// * h_mod - Handle of the MVCI module
240/// * p_resource_id_data - Pointer to store resource ID data
241/// * p_resource_id_list - Pointer to store resource ID list
242pub type PduGetResourceIdsFn = extern "system" fn(
243    h_mod: u32,
244    p_resource_id_data: *mut RscData,
245    p_resource_id_list: *mut *mut RscIdItem,
246) -> PduError;
247
248/// Gets a list of conflicting resources
249///
250/// ## Parameters
251/// * resource_id - Resource ID to check for conflicts
252/// * p_input_module_list - Pointer to module to check for conflicts
253/// * p_output_conflict_list - Pointer of destination to store a list of conflicting resources
254pub type PduGetConflictingResourcesFn = extern "system" fn(
255    resource_id: u32,
256    p_input_module_list: *mut ModuleItem,
257    p_output_conflict_list: *mut *mut RscConflictItem,
258) -> PduError;
259
260/// Gets a list of unique response IDs from a ComLogicalLink
261///
262/// ## Parameters
263/// * h_mod - Handle of the MVCI module
264/// * h_cll - Handle of the ComLogicalLink
265/// * p_unique_resp_id_table - Pointer to store the list of unique response IDs
266pub type PduGetUniqueRespIdTableFn = extern "system" fn(
267    h_mod: u32,
268    h_cll: u32,
269    p_unique_resp_id_table: *mut *mut UniqueRespIdTableItem,
270) -> PduError;
271
272/// Sets a unique response ID table for the ComLogicalLink
273///
274/// ## Parameters
275/// * h_mod - Handle of the MVCI module
276/// * h_cll - Handle of the ComLogicalLink
277/// * p_unique_resp_id_table - Pointer to the unique response ID table to set
278pub type PduSetUniqueRespIdTableFn = extern "system" fn(
279    h_mod: u32,
280    h_cll: u32,
281    p_unique_resp_id_table: *mut UniqueRespIdTableItem,
282) -> PduError;
283
284/// Determines if a MVCI module is available to connect
285///
286/// ## Parameters
287/// * h_mod - Handle of the MVCI module to try and connect
288pub type PduModuleConnectFn = extern "system" fn(h_mod: u32) -> PduError;
289
290/// Tries to close all communication channels of a MVCI module
291///
292/// ## Parameters
293/// * h_mod - Handle of the MVCI module to disconnect
294pub type PduModuleDisconnectFn = extern "system" fn(h_mod: u32) -> PduError;
295
296/// Obtains the current hardware clock of the MVCI module
297///
298/// ## Parameters
299/// * p_timestamp - Pointer to store timestamp in microseconds
300pub type PduGetTimestampFn = extern "system" fn(h_mod: u32, p_timestamp: *mut u32) -> PduError;