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