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-unwind" 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-unwind" 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-unwind" fn(
26    h_mod: u32,
27    h_cll: u32,
28    ioctl_command_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-unwind" 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-unwind" 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-unwind" fn(
70    h_mod: u32,
71    h_cll: u32,
72    p_error_code: *mut PduErrorEvt,
73    p_h_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-unwind" 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-unwind" fn(
95    h_mod: u32,
96    p_rsc_data: *mut RscData,
97    resource_id: u32,
98    p_cll_tag: *mut c_void,
99    p_h_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-unwind" 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-unwind" 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-unwind" 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 =
131    extern "system-unwind" fn(h_mod: u32, h_cll: u32, lock_mask: u32) -> PduError;
132
133/// Unlocks a physical resource from a ComLogicalLink that has exclusive access to it
134///
135/// ## Parameters
136/// * h_mod - Handle of the MVCI module
137/// * h_cll - Handle of the ComLogicalLink to unlock the resource from
138/// * lock_mask - Bit encoded mask to request for release
139pub type PduUnlockResourceFn =
140    extern "system-unwind" fn(h_mod: u32, h_cll: u32, lock_mask: u32) -> PduError;
141
142/// Obtains a communication or bus ComParam out of the MVCIs working buffer of a ComLogicalLink
143///
144/// ## Parameters
145/// * h_mod - Handle of the MVCI module
146/// * h_cll - Handle of the ComLogicalLink
147/// * param_id - ID value of the ComParam that is being requested
148/// * p_param_item - Pointer to store the requested ComParam into
149pub type PduGetComParamFn = extern "system-unwind" fn(
150    h_mod: u32,
151    h_cll: u32,
152    param_id: u32,
153    p_param_item: *mut *mut ParamItem,
154) -> PduError;
155
156/// Sets a com param on a ComLogicalLink
157///
158/// ## Parameters
159/// * h_mod - Handle of the MVCI module
160/// * h_cll - Handle of the ComLogicalLink to set the param on
161/// * p_param_item - Pointer to a ComParams to set
162pub type PduSetComParamFn =
163    extern "system-unwind" fn(h_mod: u32, h_cll: u32, p_param_item: *mut ParamItem) -> PduError;
164
165/// Creates and starts a ComPrimitive
166///
167/// ## Parameters
168/// * h_mod - Handle of the MVCI module
169/// * h_cll - Handle of the ComLogicalLink to start the ComPrimitive on
170/// * cop_type - Type of ComPrimitive to start
171/// * cop_data_size - Size of the data for the ComPrimitive
172/// * p_cop_data - Pointer to data for the ComPrimitive
173/// * p_cop_tag - Application specific tag
174/// * ph_cop - Reference for storing the returned ComPrimitive handle
175pub type PduStartComPrimitiveFn = extern "system-unwind" fn(
176    h_mod: u32,
177    h_cll: u32,
178    cop_type: PduCopt,
179    cop_data_size: u32,
180    p_cop_data: *mut u8,
181    p_cop_ctrl_data: *mut CopCtrlData,
182    p_cop_tag: *mut c_void,
183    p_h_cop: *mut u32,
184) -> PduError;
185
186/// Cancels and stops a ComPrimitive
187///
188/// ## Parameters
189/// * h_mod - Handle of the MVCI module
190/// * h_cll - Handle of the ComLogicalLink
191/// * h_cop - Handle of the ComPrimitive
192pub type PduCancelComPrimitiveFn =
193    extern "system-unwind" fn(h_mod: u32, h_cll: u32, h_cop: u32) -> PduError;
194
195/// Retrieves event data for a given event source
196///
197/// ## Parameter
198/// * h_mod - Handle of the MVCI module
199/// * h_cll - Handle of the ComLogicalLink
200/// * p_event_item - Pointer to store the event item
201pub type PduGetEventItemFn = extern "system-unwind" fn(
202    h_mod: u32,
203    h_cll: u32,
204    p_event_item: *mut *mut EventItem,
205) -> PduError;
206
207/// Destroys a given item
208///
209/// ## Parameters
210/// * p_item - Pointer to item to be destroyed
211pub type PduDestroyItemFn = extern "system-unwind" fn(p_item: *mut PduItem) -> PduError;
212
213/// Registers a callback function
214///
215/// ## Parameters
216/// * h_mod - Handle of the MVCI module
217/// * h_cll - Handle of the ComLogicalLink
218/// * callback_fn - Callback function (null to deregister callback)
219pub type PduRegisterCallbackFn =
220    extern "system-unwind" fn(h_mod: u32, h_cll: u32, callback_fn: EventCallbackFn) -> PduError;
221
222/// Gets the Item ID of a given item
223///
224/// ## Parameters
225/// * pdu_object_type - Type of object
226/// * p_short_name - Short name of the object
227/// * p_pdu_object_id - Reference to store the object ID
228pub type PduGetObjectIdFn = extern "system-unwind" fn(
229    pdu_object_type: PduObjt,
230    p_short_name: *mut u8,
231    p_pdu_object_id: *mut u32,
232) -> PduError;
233
234/// Object module information
235///
236/// ## Parameters
237/// * p_module_id_list - Pointer for storing the pointer of the module information list
238pub type PduGetModuleIdsFn =
239    extern "system-unwind" fn(p_module_id_list: *mut *mut ModuleItem) -> PduError;
240
241/// Get a list of resource IDs
242///
243/// ## Parameters
244/// * h_mod - Handle of the MVCI module
245/// * p_resource_id_data - Pointer to store resource ID data
246/// * p_resource_id_list - Pointer to store resource ID list
247pub type PduGetResourceIdsFn = extern "system-unwind" fn(
248    h_mod: u32,
249    p_resource_id_data: *mut RscData,
250    p_resource_id_list: *mut *mut RscIdItem,
251) -> PduError;
252
253/// Gets a list of conflicting resources
254///
255/// ## Parameters
256/// * resource_id - Resource ID to check for conflicts
257/// * p_input_module_list - Pointer to module to check for conflicts
258/// * p_output_conflict_list - Pointer of destination to store a list of conflicting resources
259pub type PduGetConflictingResourcesFn = extern "system-unwind" fn(
260    resource_id: u32,
261    p_input_module_list: *mut ModuleItem,
262    p_output_conflict_list: *mut *mut RscConflictItem,
263) -> PduError;
264
265/// Gets a list of unique response IDs from a ComLogicalLink
266///
267/// ## Parameters
268/// * h_mod - Handle of the MVCI module
269/// * h_cll - Handle of the ComLogicalLink
270/// * p_unique_resp_id_table - Pointer to store the list of unique response IDs
271pub type PduGetUniqueRespIdTableFn = extern "system-unwind" fn(
272    h_mod: u32,
273    h_cll: u32,
274    p_unique_resp_id_table: *mut *mut UniqueRespIdTableItem,
275) -> PduError;
276
277/// Sets a unique response ID table for the ComLogicalLink
278///
279/// ## Parameters
280/// * h_mod - Handle of the MVCI module
281/// * h_cll - Handle of the ComLogicalLink
282/// * p_unique_resp_id_table - Pointer to the unique response ID table to set
283pub type PduSetUniqueRespIdTableFn = extern "system-unwind" fn(
284    h_mod: u32,
285    h_cll: u32,
286    p_unique_resp_id_table: *mut UniqueRespIdTableItem,
287) -> PduError;
288
289/// Determines if a MVCI module is available to connect
290///
291/// ## Parameters
292/// * h_mod - Handle of the MVCI module to try and connect
293pub type PduModuleConnectFn = extern "system-unwind" fn(h_mod: u32) -> PduError;
294
295/// Tries to close all communication channels of a MVCI module
296///
297/// ## Parameters
298/// * h_mod - Handle of the MVCI module to disconnect
299pub type PduModuleDisconnectFn = extern "system-unwind" fn(h_mod: u32) -> PduError;
300
301/// Obtains the current hardware clock of the MVCI module
302///
303/// ## Parameters
304/// * p_timestamp - Pointer to store timestamp in microseconds
305pub type PduGetTimestampFn =
306    extern "system-unwind" fn(h_mod: u32, p_timestamp: *mut u32) -> PduError;