Bus Custom Code Interface Handling
Bus Custom Code Interface Handling
If possible, always provide the serial number of the hardware, the relevant dSPACE License
ID, or the serial number of the CmContainer in your support request.
Important Notice
This publication contains proprietary information that is protected by copyright. All rights
are reserved. The publication may be printed for personal or internal use provided all the
proprietary markings are retained on all printed copies. In all other cases, the publication
must not be copied, photocopied, reproduced, translated, or reduced to any electronic
medium or machine-readable form, in whole or in part, without the prior written consent
of dSPACE GmbH.
This publication and the contents hereof are subject to change without notice.
Contents
3
May 2024 Bus Custom Code Interface Handling
Contents
DsBusCustomCodeUserCodePduFeatureHandle............................................. 71
DsBusCustomCodeUserPortHandle................................................................ 72
4
Bus Custom Code Interface Handling May 2024
Contents
DsBusCustomCodeSecuredIPdu_getAuthDataFreshnessLength.................... 126
DsBusCustomCodeSecuredIPdu_getAuthDataFreshnessStartPosition. .......... 127
DsBusCustomCodeSecuredIPdu_getAuthInfoTxLength...................... .......... 128
DsBusCustomCodeSecuredIPdu_getAuthPduHeaderLength......................... 130
DsBusCustomCodeSecuredIPdu_getAuthenticPdu....................................... 131
DsBusCustomCodeSecuredIPdu_getAuthenticationBuildAttempts..... .......... 132
DsBusCustomCodeSecuredIPdu_getAuthenticationRetries........................... 134
DsBusCustomCodeSecuredIPdu_getDataId.................................................. 135
DsBusCustomCodeSecuredIPdu_getFreshnessCounterSyncAttempts............ 136
DsBusCustomCodeSecuredIPdu_getFreshnessTimestampPeriodFactor.......... 138
DsBusCustomCodeSecuredIPdu_getFreshnessValueId.................................. 139
DsBusCustomCodeSecuredIPdu_getFreshnessValueLength................ .......... 141
DsBusCustomCodeSecuredIPdu_getFreshnessValueTxLength....................... 142
DsBusCustomCodeSecuredIPdu_getKeyId.................................................... 143
DsBusCustomCodeSecuredIPdu_getMessageLinkLength.............................. 144
DsBusCustomCodeSecuredIPdu_getMessageLinkPosition.................. .......... 146
DsBusCustomCodeSecuredIPdu_getRxSecurityVerification........................... 147
DsBusCustomCodeSecuredIPdu_getSecuredAreaLength.............................. 149
DsBusCustomCodeSecuredIPdu_getSecuredAreaOffset..................... .......... 151
DsBusCustomCodeSecuredIPdu_getTimeStampRxAcceptanceWindo
w................................................................................................................ 152
DsBusCustomCodeSecuredIPdu_getUseAsCryptographicPdu....................... 153
DsBusCustomCodeSecuredIPdu_getUseAuthDataFreshness......................... 155
DsBusCustomCodeSecuredIPdu_getUseFreshnessTimestamp....................... 156
DsBusCustomCodeSignal_getEndianness.......................................... .......... 158
DsBusCustomCodeSignal_getLength........................................................... 159
DsBusCustomCodeSignal_getStartBitPosition.............................................. 160
DsBusCustomCodeUserCodePduFeature_getNumberOfUserPorts................ 162
DsBusCustomCodeUserCodePduFeature_getNumberOfUserSignals............. 163
DsBusCustomCodeUserCodePduFeature_getResult........................... .......... 164
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTrigg
ering........................................................................................................... 166
DsBusCustomCodeUserCodePduFeature_getUserPorts................................ 168
DsBusCustomCodeUserCodePduFeature_getUserSignals............................. 170
DsBusCustomCodeUserCodePduFeature_setResult...................................... 171
DsBusCustomCodeUserPort_getDirection.................................................... 173
DsBusCustomCodeUserPort_getPortData.................................................... 174
DsBusCustomCodeUserPort_setPortData..................................................... 176
Index 179
5
May 2024 Bus Custom Code Interface Handling
Contents
6
Bus Custom Code Interface Handling May 2024
About This Document
Content Introduces you to the Bus Custom Code interface. The Bus Custom Code
interface is a common API interface provided by dSPACE that is supported
by bus implementation software, such as the Bus Manager or the FlexRay
Configuration Package. By using the Bus Custom Code interface, you can
integrate user code implementations that provide user-specific bus functionality
in bus implementation software.
This document introduces you to the fields of application and to the basic
principles of working with the Bus Custom Code interface. Additionally, it
provides reference information on the handles and functions of the Bus Custom
Code interface.
Target group This document is primarily intended for engineers who implement user-specific
bus functionality via user code implementations in bus implementation software.
Symbol Description
Indicates a hazardous situation that, if not avoided,
V DANGER
will result in death or serious injury.
Indicates a hazardous situation that, if not avoided,
V WARNING could result in death or serious injury.
Indicates a hazardous situation that, if not avoided,
V CAUTION could result in minor or moderate injury.
Indicates a hazard that, if not avoided, could result in
NOTICE
property damage.
Indicates important information that you should take
Note
into account to avoid malfunctions.
Indicates tips that can make your work easier.
Tip
7
May 2024 Bus Custom Code Interface Handling
About This Document
Symbol Description
Indicates a link that refers to a definition in the
glossary, which you can find at the end of the
document unless stated otherwise.
Follows the document title in a link that refers to
another document.
Naming conventions dSPACE user documentation uses the following naming conventions:
Special Windows folders Windows‑based software products use the following special folders:
Accessing dSPACE Help and After you install and decrypt Windows‑based dSPACE software, the
PDF files documentation for the installed products is available in dSPACE Help and as PDF
files.
dSPACE Help (local) You can open your local installation of dSPACE Help:
§ On its home page via Windows Start Menu
§ On specific content using context-sensitive help via F1
PDF files You can access PDF files via the icon in dSPACE Help. The PDF
opens on the first page.
8
Bus Custom Code Interface Handling May 2024
Basics on the Bus Custom Code Interface
Implementing the
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTri
ggering Function in the User Code.......................................................... 26
Provides detailed information on implementing the
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTrig
gering function in the user code depending on the specific use
scenario.
9
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
Overview The Bus Custom Code interface is a dSPACE API interface that is supported
by bus implementation software, such as the Bus Manager or the FlexRay
Configuration Package. By using the Bus Custom Code interface, you can
implement user code in executable applications, i.e., in real‑time applications
and/or offline simulation applications. Via user code, you can provide
additional functionality to the bus implementation software, such as user-
specific algorithms for calculating authentication information in secure onboard
communication scenarios. However, the additionally supported functionality
depends on the specific bus implementation software.
Bus implementation software The Bus Custom Code interface is supported by bus implementation software,
supporting the Bus Custom i.e., by the following dSPACE software tools:
Code interface § ConfigurationDesk
§ Bus Manager (stand-alone)
§ RTI CAN MultiMessage Blockset
§ FlexRay Configuration Package
§ Ethernet Configuration Package
Depending on the dSPACE software tool, not all of the functionalities provided
by the Bus Custom Code interface might be supported.
User code and the Bus Custom The Bus Custom Code interface lets you implement user code and its
Code interface functionalities in executable applications, i.e., in real-time applications and/or
offline simulation applications.
User code User code is C code or C++ code that contains user-specific
algorithms. You can use user-specific algorithms to provide additional
functionality to the bus implementation software, for example, for calculating
checksum or counter signal values or generating authentication information in
secure onboard communication (SecOC) scenarios. A user code implementation
consists of one or more source files (*.c, *.cpp) and optional include files (*.h,
*.hpp).
10
Bus Custom Code Interface Handling May 2024
Introduction to the Bus Custom Code Interface
Bus Custom Code interface The Bus Custom Code interface is a C-based
API interface provided by dSPACE. The interface is required to implement user
code and its functionalities in executable applications. In general, the Bus
Custom Code interface lets you do the following:
§ Specify a user code ID for each user code implementation. This ID is required
to unambiguously reference specific user code implementations in the bus
implementation software.
§ Initialize the functionalities provided by user code in the executable
application.
§ Exchange data between the user code and the bus implementation software,
for example, to access properties of secured IPDUs or write calculated
checksum values to ISignals of a PDU.
For more information, refer to Basic Principles of the Bus Custom Code Interface
on page 12.
Implementing user code in To implement user code in executable applications, you must extend the user
executable applications code by functions of the Bus Custom Code interface, e.g., to write data to
or read data from the user code. For more information, refer to Integrating
Functions of the Bus Custom Code Interface in the User Code on page 17.
Additionally, you must add the user code implementation (e.g., source files and
include files) to the bus implementation software. For more information, refer to:
11
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
Modules of the Bus Custom The Bus Custom Code interface is a C-based API interface that consists of three
Code interface modules:
Module Purpose
DsBusCustomCode Provides common type definitions and function declarations that are independent of a specific
use scenario.
DsBusCustomCode_SecOC Provides type definitions and function declarations that are required if you want to implement
secure onboard communication (SecOC) via user code in executable applications, i.e., in
real‑time applications and/or offline simulation applications.
DsBusCustomCode_PduUserCode Provides type definitions and function declarations that are required if you want to implement
additional PDU-based functionalities via user code in executable applications, such as user-
specific algorithms for calculating checksum signal values.
Note
The DsBusCustomCode_PduUserCode module can be used only with the Bus Manager,
i.e., only the Bus Manager can parameterize the functions of this module. You cannot
use this module with any other bus implementation software.
DsBusCustomCode module
Type definitions and function declarations for Type definitions and function declarations for
secured IPDUs and SecOC-related features in PDUs to use the PDU User Code feature of the
secure onboard communication scenarios Bus Manager
For an overview of the handles and functions that are provided by the modules,
refer to Overview of the Handles and Their Functions on page 20.
Addressing elements via The Bus Custom Code interface uses handles to address elements such as
handles PDUs and access their data at run time. For each element that is affected by
the user code, a unique handle is generated during the initialization phase
of the executable application (i.e., real-time application or offline simulation
application). Via these handles, functions of the Bus Custom Code interface can
get and set data, even across subsequent function calls. The generated handles
are persistent at run time.
12
Bus Custom Code Interface Handling May 2024
Basic Principles of the Bus Custom Code Interface
Syntax of Bus Custom Code Almost all functions provided by the Bus Custom Code interface use the same
functions syntax, as shown in the following example:
Position Purpose
1 Constant prefix
Used by all functions of the Bus Custom Code interface.
2 Handle identification
Determines the handle type that is addressed by the function and expected as
the function's first parameter.
3 Get/set definition
Determines whether data is read from (get) or written to (set) the element
that is addressed by the function.
4 Addressed element
Determines the element that is addressed by the function and expected as the
function's second parameter.
5 First function parameter
Handle type that is expected according to position 2.
6 Second function parameter
Element that is addressed according to position 4.
Working with return values The Bus Custom Code interface provides return values that indicate whether
functions of the Bus Custom Code interface are executed correctly. For example,
the return values can indicate that a required parameter is not specified or an
addressed handle is invalid.
However, the return values of the Bus Custom Code interface do not provide
the results of user code functionalities, e.g., whether a received counter value
matches the expected counter value.
For this purpose, you can specify user-defined return values. You can pass such
user-defined return values to suitable set functions of the Bus Custom Code
interface, e.g., to the DsBusCustomCodeUserCodePduFeature_setResult
function of the DsBusCustomCode_PduUserCode module.
Parameter data of Bus Custom In general, the functions of the Bus Custom Code interface can be used for the
Code functions following purposes:
§ Exchange data between the code that is generated by the bus implementation
software and the user code.
§ Store run-time data and provide it to the user code during subsequent
function calls. In this case, the data is handled in the user code and not
13
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
directly exchanged with the bus implementation software code. For example,
this applies to data that is accessed by the user code via a data pointer.
The data that is exchanged via the bus implementation software code and the
user code can have different data sources, as shown in the following table.
If a Bus Custom Code get function is called and no data source provides data to
a function parameter, the function returns PARAMETER_NOT_SET and no data is
written to the function's output parameter.
Tip
14
Bus Custom Code Interface Handling May 2024
Run-Time Behavior of Code That Uses Functions of the Bus Custom Code Interface
Run-Time Behavior of Code That Uses Functions of the Bus Custom Code
Interface
Initialization phase and In general, an initialization phase and an execution phase can be distinguished
execution phase to characterize the run-time behavior of code that uses functions of the Bus
Custom Code interface, as shown in the following illustration.
handle data.
§ Generate handles
2. Calls the
§ Set initial values for handle parameters
DsBusCustomCode_onPduFeatureExecution
2. Calls the
function.
DsBusCustomCode_onApplicationInit
3. Uses Bus Custom Code functions to get run-time
function.
handle data.
generate/get/set get/set
onPduFeatureExecution
onApplicationInit
Code interface
Code interface
Bus Custom
Bus Custom
Implements functions for: Implements functions for:
§ Generating handles
§ Getting handle data
§ Getting handle data § Setting handle data
§ Setting handle data
get/set get/set
§ Implements the
§ Implements the DsBusCustomCode_onPduFeatureExecution
implementation
DsBusCustomCode_onApplicationInit function.
function.
User code
15
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
Tip
Note
Execution sequence of user Even though the code that is generated by the bus implementation software is
code and other features of PDU-based, user code can also affect signals and frames of the related PDUs.
bus implementation software Additionally, signals, PDUs, and frames can be affected by other features of
the bus implementation software, e.g., by bus configuration features of the Bus
Manager. Basically, the execution sequence of the user code and other features
of the bus implementation software depends on whether the PDU is a TX or an
RX PDU, as shown in the following example.
16
Bus Custom Code Interface Handling May 2024
Integrating Functions of the Bus Custom Code Interface in the User Code
Integrating Functions of the Bus Custom Code Interface in the User Code
Overview To implement user code and its functionalities in executable applications (i.e.,
in real‑time applications and/or offline simulation applications), you must extend
the user code by functions of the Bus Custom Code interface. Some functions
of the Bus Custom Code interface are mandatory, regardless of the specific use
scenario. Additionally, there are mandatory and optional functions depending on
the use scenario.
Mandatory user code ID For each user code implementation, one unique user code ID must be specified.
The user code ID is required to unambiguously reference specific user code
implementations in the bus implementation software.
17
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
To specify the user code ID, exactly one source file of a user code implementation
must start with the following definition:
The user code ID must be a unique C-compliant string, i.e., only letters, numbers,
and '_' are allowed. However, the first character must not be a number. The
string must be at least one character long and the recommended maximum
string length is 64 characters.
Note
§ There must not be any definitions, includes, function calls, etc. before the
definition of the user code ID.
§ If a user code implementation consists of multiple source files, only one
source file must contain the definition of the user code ID.
§ To use functions of the Bus Custom Code interface at run time, their
function definitions must be included in the source file that contains the
definition of the user code ID.
Note
Both functions must be implemented exactly once in the source file that
contains the definition of the user code ID.
18
Bus Custom Code Interface Handling May 2024
Integrating Functions of the Bus Custom Code Interface in the User Code
The specific initialization and execution of the user code depends on your use
scenario.
Tip
Use-scenario-specific content Mandatory include files Depending on your use scenario, you must include
one of the following include files in your user code implementation:
Note
This use scenario is supported only by the Bus Manager and not by
any other bus implementation software.
Note
The include file must be included in the source file that contains the
definition of the user code ID.
Note
This use scenario is supported only by the Bus Manager and not by any
other bus implementation software.
19
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
General recommendations To ensure optimum run‑time performance and predictable run‑time behavior,
note the following points for integrating functions of the Bus Custom Code
interface in your user code:
§ The DsBusCustomCode_onApplicationInit function does not influence
the real-time performance of the user code during the execution phase.
For optimum performance, it is therefore recommended to implement time-
consuming operations such as malloc or non-deterministic function calls in
the DsBusCustomCode_onApplicationInit function.
§ Use the DSBUSCUSTOMCODE_CHECK_NULL and DSBUSCUSTOMCODE_TRY
macros, which are defined by the common DsBusCustomCode module, to
check each pointer and function parameter once as early as possible.
Overview The Bus Custom Code interface provides a set of handles that let you access
elements such as PDUs or PDU features. For specific handles, functions are
available that let you access element properties: Get functions provide a read
access to properties, set functions provide write access.
The following illustrations provide a graphical overview of the public handles and
functions that are provided by the modules of the Bus Custom Code interface.
20
Bus Custom Code Interface Handling May 2024
Overview of the Handles and Their Functions
Handles and functions The following illustration provides an overview of the handles and functions of
provided by the common the common DsBusCustomCode module, and the inheritance of the functions.
DsBusCustomCode module
Set Functions
Communication Cluster -- Signal
DsBusCustomCodeCommunicationClusterHandle DsBusCustomCodeSignalHandle
Inherited functions
Inherited functions
Get Functions Get Functions
-- getEndianness: DsBusCustomCode_ByteOrderType
getLength: uint32
Set Functions getStartBitPosition: uint32
--
Set Functions
--
Inherited functions
ECU PDU
DsBusCustomCodeEcuHandle DsBusCustomCodePduHandle
Set Functions
--
PDU Feature
DsBusCustomCodePduFeatureHandle
Get Functions
getCommunicationCluster: DsBusCustomCodeCommunicationClusterHandle
getEcu: DsBusCustomCodeEcuHandle
getFeatureDataPtr: uint8*
getPdu: DsBusCustomCodePduHandle
Set Functions
setFeatureDataPtr(uint8*): void
21
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
Handles and functions The following illustration provides an overview of the handles and functions of
provided by the the DsBusCustomCode_SecOC module, and the inheritance of the functions.
DsBusCustomCode_SecOC
module
22
Bus Custom Code Interface Handling May 2024
Using Bus Custom Code Functions with Bus Implementation Software
Handles and The following illustration provides an overview of the handles and functions
functions provided by of the DsBusCustomCode_PduUserCode module, and the inheritance of the
the DsBusCustomCode_ functions.
PduUserCode module
Get Functions
getDirection: boolean
getPortData: float64
Get Functions
getResult: uint32
getNumberOfUserSignals: uint32
getUserSignals: DsBusCustomCodeSignalHandle*
getNumberOfUserPorts: uint32
getUserPorts: DsBusCustomCodeUserPortHandle*
getRuntimeCanFrameTriggering: DsBusCustomCodeRuntimeCanFrameTriggeringType
Set Functions
setResult: uint32
Using Bus Custom Code In general, user code that uses functions of the Bus Custom Code interface can
functions with different be used with all bus implementation software tools. However, not all functions
bus implementation software of the Bus Custom Code interface can be used with each bus implementation
tools software tool. For example, because of the following reasons:
§ A function requires data of a specific communication matrix attribute but this
attribute is not evaluated by a bus implementation software tool.
§ A function requires data from a property of the bus implementation software
but this property is not available for a bus implementation software tool.
For more information on function parameters and return values, refer to Basic
Principles of the Bus Custom Code Interface on page 12.
23
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
Mapping of Bus Custom The following table provides an overview of the public Bus Custom Code
Code functions to bus functions and with which bus implementation software tool they can be used.
implementation software
24
Bus Custom Code Interface Handling May 2024
Using Bus Custom Code Functions with Bus Implementation Software
25
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
Implementing the
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTriggering
Function in the User Code
Note
Note
26
Bus Custom Code Interface Handling May 2024
Implementing the DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTriggering Function in the User Code
27
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
28
Bus Custom Code Interface Handling May 2024
Implementing the DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTriggering Function in the User Code
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTriggering
function as follows:
§ To access the data of PDUs that are assigned to the Manipulation part,
implement the DsBusCustomCodeUserCodePduFeature_
getRuntimeCanFrameTriggering function in that part that is only executed
for TX PDUs.
§ To access the data of RX PDUs that are assigned to the Simulated ECUs
part or of PDUs that are assigned to the Inspection part, implement the
DsBusCustomCodeUserCodePduFeature_
getRuntimeCanFrameTriggering function in that part that is only executed
for RX PDUs.
29
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
45 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserPort_setPortData(UserPorts[2],
46 My_RuntimeCanStruct.FrameBehavior));
47 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserPort_setPortData(UserPorts[3],
48 My_RuntimeCanStruct.BitRateSwitch));
49
50 }
51 /* If the PDU is an RX PDU, the Else part of the If-Else loop is executed. */
52 else
53 {
54 /* Access the user ports of the PDU User Code feature of the RX PDU.
55 * Get the user port array of the RX PDU from the PDU's PduFeatureHandle. */
56 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserCodePduFeature_getUserPorts(PduFeatureHandle,
57 &UserPorts));
58
59 /* Get the run-time CAN frame triggering data and store the data in the My_RuntimeCanStruct struct.
60 * The function can get the data only if the RX PDU is assigned to the Simulated ECUs or Inspection part. */
61 DSBUSCUSTOMCODE_TRY(featureDescriptor,
62 DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTriggering(PduFeatureHandle, &My_RuntimeCanStruct));
63
64 /* Write the data of the My_RuntimeCanStruct struct to the user ports. */
65 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserPort_setPortData(UserPorts[0],
66 My_RuntimeCanStruct.Identifier));
67 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserPort_setPortData(UserPorts[1],
68 My_RuntimeCanStruct.AddressingMode));
69 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserPort_setPortData(UserPorts[2],
70 My_RuntimeCanStruct.FrameBehavior));
71 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserPort_setPortData(UserPorts[3],
72 My_RuntimeCanStruct.BitRateSwitch));
73
74 }
75 return E_OK;
76
77 }
Using different user code In general, you can use the same user code implementation for both use
implementations scenarios. Only if you want to access the run‑time data of TX PDUs that are
assigned to the Simulated ECUs part and of PDUs that are assigned to the
Manipulation part, you have to use different user code implementations.
Tip
Integrating Functions of the Bus Custom Code Interface in the User Code................................ 17
30
Bus Custom Code Interface Handling May 2024
Restrictions for Working with the Bus Custom Code Interface
References
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTriggering.............................. 166
Overview If you work with the Bus Custom Code interface, the following restrictions apply.
Restrictions for working with The Bus Custom Code interface is specified in the <bus custom code module
the files of the Bus Custom name>.c, <bus custom code module name>.h, and <bus custom code
Code interface module name>_Internal.h files. These files are automatically installed when
you install a bus implementation software tool.
Restrictions for using reserved The Bus Custom Code interface provides functions that are reserved for internal
functions use only. These functions are specified in the <bus custom code module
name>_Internal.h files. Do not use any of these functions in your user code.
Restrictions for using The DsBusCustomCode_PduUserCode module can be used only with the Bus
the DsBusCustomCode_ Manager. You cannot use this interface with any other bus implementation
PduUserCode module software.
31
May 2024 Bus Custom Code Interface Handling
Basics on the Bus Custom Code Interface
32
Bus Custom Code Interface Handling May 2024
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
Note
33
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
At run time, the algorithms apply to all PDUs for which the PDU User Code
feature of the Bus Manager is added and that reference the user code ID of this
source file.
Defining the user code ID The first element in the source file is the definition of a user code ID, which is
named UserCRCDemo in this example:
1 /* Start of user code source file */
2 /* Define user code ID */
3 #define DS_BUS_CUSTOM_FEATURE_NAME UserCRCDemo
For each user code implementation, one unique user code ID must be specified.
To apply the algorithms of the user code implementation to a PDU, you must
reference the specified user code ID via the PDU User Code feature of this PDU
in the ConfigurationDesk application.
Including required include After the definition of the user code ID, required include files are included:
files
1 /* Mandatory include file */
2 #include <DsBusCustomCode_PduUserCode.h>
3
4 /* Further required include files */
5 #include <stdio.h>
6 #include <stdlib.h>
The stdio.h and stdlib.h files are header files of the standard C library,
providing definitions and declarations of the C library. It depends on your user
code whether including these files and/or other include files is required.
Defining return values In this example, the following return values are defined to provide status
information on the received counter and checksum values at run time:
1 #define CUSTOM_CRC_OK 0x00 /* Expected checksum value received */
2 #define CUSTOM_CRC_FAILED 0x01 /* Unexpected checksum value received */
34
Bus Custom Code Interface Handling May 2024
Example of Implementing User-Specific PDU Functionalities via the Bus Custom Code Interface
In this example, the definition of these return values is global, i.e., the values can
be used by all functions of this source file.
Tip
Saving current counter data At run time, functions of this user code example require access to the
initialization state of the counter and the current counter value. In most cases,
the current counter value is the value that was calculated during the previous
execution of the PDU User Code feature.
Tip
Initializing the user code for The user code must be initialized for each PDU to which the PDU
each PDU User Code feature is added. For this purpose, you must implement the
DsBusCustomCode_onApplicationInit function. During the initialization
phase of the executable application, this function is called for each PDU that
is affected by the PDU User Code feature.
In this example, the user code is initialized for each PDU as follows:
1 Std_ReturnType DsBusCustomCode_onApplicationInit(DsBusCustomCodePduFeatureHandle PduFeatureHandle)
2 {
3 /* Declare data pointers. */
4 uint8* featureDataPtr;
5 char* featureDescriptor;
6 struct UserCode_FeatureData* featureInstanceData;
7
8 /* Execute the DSBUSCUSTOMCODE_CHECK_NULL macro to check whether the PduFeatureHandle is NULL.
9 * If it is, a message is written to the application log and the DsBusCustomCode_onApplicationInit function
10 * returns E_NOT_OK. */
11 DSBUSCUSTOMCODE_CHECK_NULL(g_DsBusCustomCodeDefaultDescriptor, PduFeatureHandle);
12 DsBusCustomCode_getDescriptor(PduFeatureHandle, &featureDescriptor);
13
14 /* Create an instance of the UserCode_FeatureData struct to store PDU-specific feature data.
15 * Assign the instantiated struct to the featureInstanceData pointer.
35
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
Tip
Executing the user code for To execute the user code for each PDU to which the PDU User Code feature is
each PDU added, you must implement the DsBusCustomCode_onPduFeatureExecution
function. This function is called each time the transmission of an affected PDU
is triggered or the PDU is received. With each function call, PDU data (e.g.,
direction, payload length) and data of the PDU User Code feature (e.g., function
port values) is provided to the user code.
36
Bus Custom Code Interface Handling May 2024
Example of Implementing User-Specific PDU Functionalities via the Bus Custom Code Interface
4 * the PDU User Code feature is added, regadless of the PDU direction. */
5
6 /* Part 2 and 3: If-Else loop that checks whether the PDU is a TX PDU. */
7 if (isTx)
8 {
9 /* Part 2: Executed only if the PDU is a TX PDU. */
10 }
11 else
12 {
13 /* Part 3: Executed only if the PDU is an RX PDU. */
14 }
15 return E_OK;
16 }
37
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
34 * DsBusCustomCode_onApplicationInit function. */
35 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodePduFeature_getFeatureDataPtr(PduFeatureHandle,
36 (uint8**)&featureDataPtr));
37
38 /* Access the PduHandle and its data.
39 * Get the PduHandle of the PDU from the PDU's PduFeatureHandle. */
40 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodePduFeature_getPdu(PduFeatureHandle, &pduHandle));
41 /* Get properties of the PDU from its PduHandle */
42 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodePdu_getSduLength(pduHandle, &IPdu_SduLength));
43 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodePdu_getSduDataPtr(pduHandle, &IPdu_SduDataPtr));
44 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodePdu_getIsTx(pduHandle, &isTx));
45
46 /* Access the user signals of the PDU.
47 * Get the user signal array of the PDU from the PDU's PduFeatureHandle. */
48 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserCodePduFeature_getUserSignals(PduFeatureHandle,
49 &Signals));
50 /* Get the number of user signals of the PDU from the PDU's PduFeatureHandle. */
51 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserCodePduFeature_getNumberOfUserSignals(
52 PduFeatureHandle, &SignalCount));
53
54 /* Get the start bit position of the first two signals in the signal array.
55 * Assign the ISignalCrcPos and ISignalCounterPos variables to the start bit position. */
56 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSignal_getStartBitPosition(Signals[0], &ISignalCrcPos));
57 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSignal_getStartBitPosition(Signals[1],
58 &ISignalCounterPos));
59
60 /* Access the user ports of the PDU.
61 * Get the user port array of the PDU from the PDU's PduFeatureHandle. */
62 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserCodePduFeature_getUserPorts(PduFeatureHandle,
63 &UserPorts));
64
65 /* Specify initial values for some variables of each PDU feature handle. */
66 tmpcrcval = 0;
67 tmpPos = IPdu_SduLength;
68 tmpCounterPos = ISignalCounterPos >> 3;
69 tmpCrcPos = ISignalCrcPos >> 3;
70
71 /* End of part 1, i.e., end of the common part of the DsBusCustomCode_onPduFeatureExecution function. */
72
73 /* Part 2 and 3: If-Else loop that checks whether the PDU is a TX PDU. */
74 if (isTx)
75 {
76 /* Part 2: Executed only if the PDU is a TX PDU.
77 * For details, see below. */
78 }
79 else
80 {
81 /* Part 3: Executed only if the PDU is an RX PDU.
82 * For details, see below. */
83 }
84
85 /* Return whether DsBusCustomCode_onPduFeatureExecution function is implemented correctly. */
86 return E_OK;
87 }
38
Bus Custom Code Interface Handling May 2024
Example of Implementing User-Specific PDU Functionalities via the Bus Custom Code Interface
4 ...
5
6 /* If-Else loop that checks whether the PDU is a TX PDU.
7 * Part 2: If the PDU is a TX PDU, the If part of the If-Else loop is executed. */
8 if (isTx)
9 {
10 /* Write the counter value to the allocated position of the PDU's payload. */
11 if (IPdu_SduLength > tmpCounterPos)
12 IPdu_SduDataPtr[tmpCounterPos] = (++(featureDataPtr->counter_value) & 0xFF);
13
14 /* Iterate over the PDU's data buffer and calculate the new checksum value. */
15 while (tmpPos)
16 {
17 tmpPos--;
18
19 /* Exclude the CRC position from the checksum calculation. */
20 if (tmpPos != tmpCrcPos)
21 tmpcrcval += (0xFF ^ IPdu_SduDataPtr[tmpPos]);
22 }
23
24 /* Write the calculated checksum value to the allocated position of the PDU's payload. */
25 if (IPdu_SduLength > tmpCrcPos)
26 IPdu_SduDataPtr[tmpCrcPos] = tmpcrcval;
27
28 /* Get the number of user ports of the PDU from the PDU's PduFeatureHandle. */
29 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserCodePduFeature_getNumberOfUserPorts(PduFeatureHandle,
30 &UserPortTxCount));
31
32 /* Iterate over the user port array. */
33 for (uint32 i = 0; i < UserPortTxCount; i++)
34 {
35 /* Get the direction of the user port that is accessed in the user port array. */
36 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserPort_getDirection(UserPorts[i], &portIsOut));
37
38 /* Check whether the direction of the accessed user port is In */
39 if (!portIsOut)
40 {
41 /* In case of an inport, get the port data and store it in the dataFromInPorts array */
42 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserPort_getPortData(UserPorts[i],
43 &dataFromInPorts[i]));
44 }
45 }
46 }
47 /* End of part 2, i.e., end of the TX-related part of the DsBusCustomCode_onPduFeatureExecution function. */
48
49 /* Part 3: If the PDU is an RX PDU, the Else part of the If-Else loop is executed. */
50 else
51 {
52 /* For details, see below. */
53 }
54
55 /* Return whether DsBusCustomCode_onPduFeatureExecution function is implemented correctly. */
56 return E_OK;
57 }
39
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
4 ...
5
6 /* If-Else loop that checks whether the PDU is a TX PDU. */
7 if (isTx)
8 {
9 /* Part 2: If the PDU is a TX PDU, the If part of the If-Else loop is executed. */
10 ...
11 }
12 /* Part 3: If the PDU is an RX PDU, the Else part of the If-Else loop is executed. */
13 else
14 {
15 uint32 status = CUSTOM_CRC_OK;
16 /* Check whether the RX counter has been initialized. */
17 if (IPdu_SduLength > tmpCounterPos)
18 {
19 /* If the RX counter has not been initialized yet, initialize it with the received counter value. */
20 if (!featureDataPtr->counter_is_initialized)
21 {
22 featureDataPtr->counter_value = IPdu_SduDataPtr[tmpCounterPos];
23 status |= CUSTOM_CRC_COUNTER_INITIALIZED;
24 featureDataPtr->counter_is_initialized = 1;
25 }
26 /* If the RX counter has already been initialized, increase the local counter value and
27 * compare it with the received counter value. */
28 else
29 {
30 featureDataPtr->counter_value++;
31 if ((featureDataPtr->counter_value & 0xFF) != IPdu_SduDataPtr[tmpCounterPos])
32 {
33 featureDataPtr->counter_is_initialized = 0;
34 status |= CUSTOM_CRC_COUNTER_FAILED;
35 }
36 }
37 }
38 /* Iterate over the PDU's data buffer and calculate the expected checksum value. */
39 if (IPdu_SduLength > tmpCrcPos)
40 {
41 while (tmpPos)
42 {
43 tmpPos--;
44 if (tmpPos != tmpCrcPos)
45 tmpcrcval += (0xFF ^ IPdu_SduDataPtr[tmpPos]);
46 }
47 /* Compare the expected checksum value with the received checksum value. */
48 if (tmpcrcval != IPdu_SduDataPtr[tmpCrcPos])
49 {
50 status |= CUSTOM_CRC_FAILED;
51 }
52 }
53 /* Get the number of user ports of the PDU from the PDU's PduFeatureHandle. */
54 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserCodePduFeature_getNumberOfUserPorts(PduFeatureHandle,
55 &UserPortRxCount));
56 /* Iterate over the user port array. */
57 for (uint32 i = 0; i < UserPortRxCount; i++)
58 {
59 /* Get the direction of the user port that is accessed in the user port array. */
60 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserPort_getDirection(UserPorts[i], &portIsOut));
61 /* Check whether the direction of the accessed user port is Out */
62 if (portIsOut)
63 {
64 /* In case of an outport, write the data of the dataForOutPorts array to the outport */
65 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeUserPort_setPortData(UserPorts[i],
66 dataForOutPorts[i]));
40
Bus Custom Code Interface Handling May 2024
Example of Implementing Secure Onboard Communication (SecOC) via the Bus Custom Code Interface
67 }
68 }
69 /* Write the result to the Result function port of the PDU User Code feature. */
70 DsBusCustomCodeUserCodePduFeature_setResult(PduFeatureHandle, status);
71 }
72
73 /* Return whether DsBusCustomCode_onPduFeatureExecution function is implemented correctly. */
74 return E_OK;
75 }
Overview Via the DsBusCustomCode_SecOC module of the Bus Custom Code interface,
you can implement secure onboard communication (SecOC) in executable
applications, i.e., in real‑time applications and/or offline simulation applications.
Tip
41
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
Defining the user code ID The first element in the source file is the definition of a user code ID, which is
named SecOC in this example:
1 /* Start of the UserCode_SecOC.c source file */
2 /* Define user code ID */
3 #define DS_BUS_CUSTOM_FEATURE_NAME SecOC
For each user code implementation, one unique user code ID must be specified.
To apply the algorithms of the user code implementation to secured IPDUs, the
specified user code ID must be referenced in the bus implementation software.
Including required include After the definition of the user code ID, required include files are included:
files
1 /* Mandatory include file */
2 #include <DsBusCustomCode_SecOC.h>
3
4 /* Further required include files */
5 #include <dsstd.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9
10 #include "UserCode_SecOCHelper.h"
11 #include "UserCode_Csm.h"
12 #include "UserCode_Fvm.h"
It depends on your user code whether including further files is required. In this
example, the following include files are required:
Defining return values In this example, return values are defined to provide the verification result of
received and verified authentication information. Additionally, a return value is
defined that indicates whether all required parameters are successfully initialized
during the initialization phase.
42
Bus Custom Code Interface Handling May 2024
Example of Implementing Secure Onboard Communication (SecOC) via the Bus Custom Code Interface
In this example, the definition of these return values is global, i.e., the values can
be used by all functions of this source file.
Tip
Saving current data provided At run time, functions of the user code require access to the current data of
by Crypto Service Manager the implemented functionalities of the AUTOSAR Crypto Service Manager (CSM)
and Freshness Value Manager and Freshness Value Manager (FVM). To provide access to this data, the following
structure is specified:
1 /* Struct to store current feature data */
2 struct UserCode_FeatureData
3 {
4 uint8* CsmJobHandle; /* Handle providing current data of the Crypto Service Manager functionalities */
5 uint8* TimeBaseHandle; /* Handle providing current data of the Freshness Value Manager functionalities */
6 uint32 isInitialized; /* Flag indicating whether the all required parameters are initialized */
7 };
Initializing the user code for The user code must be initialized for each secured IPDU. For this purpose, you
each secured IPDU must implement the DsBusCustomCode_onApplicationInit function. During
the initialization phase of the executable application, this function is called for
each secured IPDU.
43
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
19 DsBusCustomCode_getDescriptor(PduFeatureHandle, &featureDescriptor);
20
21 /* Create an instance of the UserCode_FeatureData struct to store PDU-specific feature data.
22 * Assign the instantiated struct to the featureInstanceData pointer.
23 * Check the pointer via the DSBUSCUSTOMCODE_CHECK_NULL macro. */
24 struct UserCode_FeatureData* featureInstanceData = (struct UserCode_FeatureData*)rtlib_malloc(sizeof(struct
25 UserCode_FeatureData));
26 DSBUSCUSTOMCODE_CHECK_NULL(g_DsBusCustomCodeDefaultDescriptor, featureInstanceData);
27 memset(featureInstanceData, 0, sizeof(struct UserCode_FeatureData));
28
29 /* Assign the instantiated UserCode_FeatureData struct via its featureInstanceData pointer to
30 * the featureDataPtr pointer.
31 * Assign the featureDataPtr pointer to the PDUFeatureHandle.
32 * Execute the DSBUSCUSTOMCODE_TRY macro to check whether the DsBusCustomCodePduFeature_setFeatureDataPtr
33 * function is called successfully.
34 * If it is not, a message is written to the application log and the DsBusCustomCode_onApplicationInit
35 * function returns E_NOT_OK. */
36 featureDataPtr = (uint8*)featureInstanceData;
37 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodePduFeature_setFeatureDataPtr(PduFeatureHandle,
38 featureDataPtr));
39
40 /* Call the UserCode_SecOC_Init function of the demo user code implementation to initialize required
41 * user code functions etc. */
42 UserCode_SecOC_Init();
43
44 /* Initialize the time base. Depending on the bus implementation software, the bus communication is either
45 * communication-cluster-based or ECU-based. Therefore, there can be one time base per communication cluster
46 * or ECU. By initialzing the time base as follows, no software-specific adaptions are required:
47 * For cluster-based bus communication, the time base is initialized for the cluster via the first If-Else loop.
48 * For ECU-based bus communcation, the cluster-based initialization of the time base is overwritten by an
49 * ECU-based initialization via the second If-Else loop.
50 * Check the handles and function calls via the DSBUSCUSTOMCODE_CHECK_NULL and DSBUSCUSTOMCODE_TRY macros. */
51 returnValue = DsBusCustomCodePduFeature_getCommunicationCluster(PduFeatureHandle, &communicationClusterHandle);
52 if (returnValue == E_OK)
53 {
54 DSBUSCUSTOMCODE_CHECK_NULL(featureDescriptor, communicationClusterHandle);
55 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCode_getName(communicationClusterHandle,
56 &communicationClusterName));
57 USERCODE_DEBUG_PRINT("Communication Cluster: %s\n", communicationClusterName);
58 timeBaseName = communicationClusterName;
59 }
60 else
61 {
62 /* No cluster available. */
63 communicationClusterHandle = NULL_PTR;
64 communicationClusterName = NULL_PTR;
65 USERCODE_DEBUG_PRINT("No Communication Cluster defined.\n");
66 timeBaseName = NULL_PTR;
67 }
68
69 returnValue = DsBusCustomCodePduFeature_getEcu(PduFeatureHandle, &ecuHandle);
70 if (returnValue == E_OK)
71 {
72 DSBUSCUSTOMCODE_CHECK_NULL(featureDescriptor, ecuHandle);
73 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCode_getName(ecuHandle, &ecuName));
74 USERCODE_DEBUG_PRINT("ECU: %s\n", ecuName);
75 /* If ECU available, initialize time base ECU-based. */
76 timeBaseName = ecuName;
77 }
78 else
79 {
80 /* No ECU available. */
81 ecuHandle = NULL_PTR;
44
Bus Custom Code Interface Handling May 2024
Example of Implementing Secure Onboard Communication (SecOC) via the Bus Custom Code Interface
82 ecuName = NULL_PTR;
83 USERCODE_DEBUG_PRINT("No ECU defined.\n");
84 timeBaseName = communicationClusterName;
85 }
86 USERCODE_DEBUG_PRINT("Timebase name: %s\n", timeBaseName);
87
88 /* Get the secured IPDU and its related authentic IPDU via their handles.
89 * Check the handles and function calls via the DSBUSCUSTOMCODE_CHECK_NULL and DSBUSCUSTOMCODE_TRY macros. */
90 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodePduFeature_getPdu(PduFeatureHandle,
91 &securedIPdu_PduHandle));
92 DSBUSCUSTOMCODE_CHECK_NULL(featureDescriptor, securedIPdu_PduHandle);
93 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecuredIPdu_getAuthenticPdu(securedIPdu_PduHandle,
94 &authenticIPdu_PduHandle));
95 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCode_getName(securedIPdu_PduHandle, &securedIPduName));
96 USERCODE_DEBUG_PRINT("Secured IPDU: %s\n", securedIPduName);
97
98 /* Get parameters that are required by the bus real-time code, such as the authentic IPDU payload length or
99 * the key ID. */
100 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodePdu_getSduLength(authenticIPdu_PduHandle,
101 &authenticIPdu_SduLength));
102 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecuredIPdu_getKeyId(securedIPdu_PduHandle, &keyId));
103 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCode_getName(authenticIPdu_PduHandle, &authenticPduName));
104 USERCODE_DEBUG_PRINT("Authentic IPDU: %s\n", authenticPduName);
105
106 /* Get the complete length of the freshness value.
107 * Calculate the data length that is to be authenticated by taking the related AUTOSAR calculation method
108 * into account. */
109 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecuredIPdu_getFreshnessValueLength(securedIPdu_PduHandle,
110 &freshnessValueLength));
111 dataToAuthentictatorLength = sizeof(uint16) + authenticIPdu_SduLength + (freshnessValueLength + 7) / 8;
112
113 /* Call the demo user code function that creates a CMAC/AES128-compliant Crypto Service Manager handle
114 * (CsmJobHandle) for the calculated authenticated length. */
115 DSBUSCUSTOMCODE_TRY(featureDescriptor, UserCode_SecOCHelper_Create_CryptoJob_For_CMAC_AES_128_Authentication(
116 &featureInstanceData->CsmJobHandle, dataToAuthentictatorLength));
117
118 /* Initialize the access to the OEM-specific key that is used for calculating the authenticator.
119 * To access the key, it must be provided by a user-specific function, e.g., getKeyFromKeyID. */
120 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecOCPduFeature_setKeyPtr(PduFeatureHandle, keyPtr));
121 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecOCPduFeature_setKeyLength(PduFeatureHandle,
122 keyLength));
123 DSBUSCUSTOMCODE_TRY(featureDescriptor, UserCode_Csm_KeyElementSet(featureInstanceData->CsmJobHandle, keyId,
124 CRYPTO_KE_MAC_KEY, keyPtr, keyLength));
125
126 /* Call the demo user code function that creates a Freshness Value Manager instance. */
127 DSBUSCUSTOMCODE_TRY(featureDescriptor, UserCode_SecOC_Fvm_Init(timeBaseName, &featureInstanceData->
128 TimeBaseHandle));
129
130 /* Get the required secured IPDU parameters and check whether they are set by using the
131 * DSBUSCUSTOMCODE_TRY macro */
132 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodePdu_getSduLength(securedIPdu_PduHandle,
133 &securedIPdu_SduLength));
134 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodePdu_getIsTx(securedIPdu_PduHandle, &isTx));
135 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecuredIPdu_getDataId(securedIPdu_PduHandle, &dataId));
136 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecuredIPdu_getFreshnessValueTxLength(
137 securedIPdu_PduHandle, &freshnessValueTxLength));
138 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecuredIPdu_getAuthInfoTxLength(securedIPdu_PduHandle,
139 &authInfoTxLength));
140
141 /* Set the SECOC_FEATUREDATAINITIALIZED return value after initializing all parameters successfully. */
142 featureInstanceData->isInitialized = SECOC_FEATUREDATAINITIALIZED;
143
144 /* Return whether DsBusCustomCode_onApplicationInit function is implemented correctly. */
45
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
Tip
Executing the user code for To execute the user code for each secured IPDU, you must implement the
each secured IPDU DsBusCustomCode_onPduFeatureExecution function. This function is called
each time the transmission of a secured IPDU is triggered or a secured IPDU is
received. With each function call, PDU data (e.g., direction, payload length) is
provided to the user code.
46
Bus Custom Code Interface Handling May 2024
Example of Implementing Secure Onboard Communication (SecOC) via the Bus Custom Code Interface
47
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
48
Bus Custom Code Interface Handling May 2024
Example of Implementing Secure Onboard Communication (SecOC) via the Bus Custom Code Interface
49
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
177 {
178 securedAreaLength = areaLength;
179 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecuredIPdu_getSecuredAreaOffset(
180 securedIPdu_PduHandle, &securedAreaOffset));
181
182 if (securedAreaOffset + securedAreaLength > authenticIPdu_ActualLength)
183 {
184 return E_NOT_OK;
185 }
186
187 actualSecuredAreaOffset = securedAreaOffset;
188 actualSecuredAreaLength = securedAreaLength;
189 }
190 /* If no secured area length is specified, set the actual secured area offset to 0 and use the entire
191 * actual length of the authentic IPDU as the actual secured area length. */
192 else
193 {
194 actualSecuredAreaOffset = 0;
195 actualSecuredAreaLength = authenticIPdu_ActualLength;
196 }
197 }
198
199 /* Access the run-time data that is written to the UserCode_FeatureData struct by using the CsmJobHandle.
200 * Get the applicable crypto job by calling the related demo user code function.
201 * Check the user code function and its Crypto_Job parameter by using the DSBUSCUSTOMCODE_TRY and
202 * DSBUSCUSTOMCODE_CHECK_NULL marcros. */
203 csmJobHandle = ((struct UserCode_FeatureData*)featureDataPtr)->CsmJobHandle;
204 DSBUSCUSTOMCODE_TRY(featureDescriptor, UserCode_CryptoJob_Get(csmJobHandle, &Crypto_Job));
205 DSBUSCUSTOMCODE_CHECK_NULL(featureDescriptor, Crypto_Job);
206 /* End of part 1, i.e., end of the common part of the DsBusCustomCode_onPduFeatureExecution function */
207
208 /* Part 2 and 3: If-Else loop that checks whether the secured IPDU is a TX IPDU. */
209 if (isTx)
210 {
211 /* Part 2: Executed only if the secured IPDU is a TX secured IPDU.
212 * For details, see below. */
213 }
214 else
215 {
216 /* Part 3: Executed only if the secured IPDU is an RX secured IPDU.
217 * For details, see below. */
218 }
219
220 /* Return whether DsBusCustomCode_onPduFeatureExecution function is implemented correctly. */
221 return E_OK;
222 }
50
Bus Custom Code Interface Handling May 2024
Example of Implementing Secure Onboard Communication (SecOC) via the Bus Custom Code Interface
12 uint32 enableFreshnessValueCalculation;
13 uint32 authenticatonType;
14 sint64 freshnessValueOffset;
15
16 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecOCTxPduFeature_getEnableFreshnessValueCalculation(
17 PduFeatureHandle, &enableFreshnessValueCalculation));
18 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecOCTxPduFeature_getEnableAuthentication(
19 PduFeatureHandle, &enableAuthentication));
20 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecOCTxPduFeature_getAuthenticationType(
21 PduFeatureHandle, &authenticatonType));
22 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecOCTxPduFeature_getFreshnessValueOffset(
23 PduFeatureHandle, &freshnessValueOffset));
24
25 /* If the secured IPDU is configured as cryptographic IPDU and a message link length is specified, call the
26 * related demo user code function to copy the required authentication information to the
27 * message link length. */
28 if (useAsCryptographicPdu)
29 {
30 if (messageLinkLength > 0)
31 {
32 UserCode_SecOCHelper_CopyBits(securedIPdu_SduDataPtr, securedIPduMessageLinkerPosition,
33 authenticIPdu_SduDataPtr, messageLinkPosition, messageLinkLength);
34 }
35 }
36 /* If the secured IPDU is not configured as cryptographic IPDU, copy the authentic IPDU to the secured IPDU,
37 * if required. Whether copying is required depends on the bus implementation software.
38 * Specifying the copying as follows increases the performance and no software-specific adaptions
39 * are required. */
40 else
41 {
42 if (securedIPdu_SduDataPtr != authenticIPdu_SduDataPtr)
43 {
44 memcpy(securedIPdu_SduDataPtr + authPduHeaderLength, authenticIPdu_SduDataPtr,
45 authenticIPdu_ActualLength);
46 }
47 }
48
49 /* If calculating the freshness value in the user code is disabled, get the user-defined freshness value. */
50 if(enableFreshnessValueCalculation == 0)
51 {
52 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecOCTxPduFeature_getUserDefinedFreshnessValue(
53 PduFeatureHandle, &freshnessValue));
54 }
55 /* If calculating the freshness value in the user code is enabled, copy the calculated freshness value and
56 * the specified TX length to local variables.
57 * Copying the data to local variables with defined data types avoids problems, e.g., if the freshness value
58 * manager specifies different data types for the accessed variables. */
59 else
60 {
61 uint32 txFreshnessLength = freshnessValueTxLength;
62 uint64 txFreshnessValue;
63 UserCode_SecOC_GetTxFreshness(((struct UserCode_FeatureData*)featureDataPtr)->TimeBaseHandle, 0,
64 (uint8*)&txFreshnessValue, &txFreshnessLength);
65 freshnessValue = txFreshnessValue;
66 }
67 USERCODE_DEBUG_PRINT("TX Freshness Value 0x%llX\n", freshnessValue);
68
69 /* Write the applicable freshness value (i.e., user-defined or calculated in user code) to the
70 * freshnessValue parameter.
71 * If specified, add the feshness offset value to the freshness value. */
72 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecOCTxPduFeature_setCalculatedFreshnessValue(
73 PduFeatureHandle, freshnessValue));
74 freshnessValue += freshnessValueOffset;
51
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
75
76 /* If caluclating the authenticator in the user code is disabled, get the user-defined authenticator value
77 * via the AuthenticatorPtr. */
78 if (enableAuthentication == 0)
79 {
80 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecOCTxPduFeature_getUserDefinedAuthenticatorPtr(
81 PduFeatureHandle, &AuthenticatorPtr));
82 DSBUSCUSTOMCODE_CHECK_NULL(featureDescriptor, AuthenticatorPtr);
83 authenticatorLength = (authInfoTxLength + 7) / 8;
84 }
85 /* If caluclating the authenticator in the user code is enabled, call the related demo user code function
86 * for calculating the authenticator. */
87 else
88 {
89 DSBUSCUSTOMCODE_TRY(featureDescriptor, UserCode_SecOCHelper_PrepareDataToAuthenticator(dataId,
90 authenticIPdu_SduDataPtr + actualSecuredAreaOffset, actualSecuredAreaLength, freshnessValue,
91 freshnessValueLength, Crypto_Job->PrimitiveInputOutput->inputPtr, &Crypto_Job->PrimitiveInputOutput->
92 inputLength));
93 USERCODE_DEBUG_PRINTDATA("TX Data to Auth", Crypto_Job->PrimitiveInputOutput->inputPtr, Crypto_Job->
94 PrimitiveInputOutput->inputLength);
95
96 AuthenticatorPtr = Crypto_Job->PrimitiveInputOutput->outputPtr;
97 authenticatorLength = Crypto_Job->jobPrimitiveInfo->primitiveInfo->resultLength;
98
99 /* According to AUTOSAR, the Crypto Service Manager expects a pre-set outputLengthPtr. Therefore, set
100 * the outputLengthPtr to the expected authenticator length. */
101 *(Crypto_Job->PrimitiveInputOutput->outputLengthPtr) = authenticatorLength;
102
103 DSBUSCUSTOMCODE_TRY(featureDescriptor, UserCode_Csm_MacGenerate(csmJobHandle, Crypto_Job->
104 PrimitiveInputOutput->mode, Crypto_Job->PrimitiveInputOutput->inputPtr, Crypto_Job->
105 PrimitiveInputOutput->inputLength, Crypto_Job->PrimitiveInputOutput->outputPtr, Crypto_Job->
106 PrimitiveInputOutput->outputLengthPtr));
107 }
108 USERCODE_DEBUG_PRINTDATA("TX MAC", AuthenticatorPtr, authenticatorLength);
109
110 /* If invalidating the authentication value is enabled, invert the most significant bit of the
111 * authenticator. */
112 if (authenticatonType != 0)
113 {
114 USERCODE_DEBUG_PRINT("====== *** MAC MANIPULATION *** ======\n");
115 AuthenticatorPtr[0] ^= 0x80;
116 USERCODE_DEBUG_PRINTDATA("TX Manipulated MAC", AuthenticatorPtr, authenticatorLength);
117 }
118
119 /* Copy the TX freshness value (i.e., the truncated freshness value) to the secured IPDU by calling the
120 * related demo user code function. */
121 uint64 freshnessValue_BigEndian = USER_CODE_INT64_TO_BE(freshnessValue);
122 uint8* freshnessPtr = (uint8*)&freshnessValue_BigEndian;
123 uint32 startpos = 64 - freshnessValueTxLength;
124 UserCode_SecOCHelper_CopyBits(securedIPdu_SduDataPtr, securedIPduFreshnessValuePosition, freshnessPtr,
125 startpos, freshnessValueTxLength);
126
127 /* Copy the TX authenticator value (i.e., the truncated authenticator value) to the secured IPDU by calling
128 * the related demo user code function. */
129 UserCode_SecOCHelper_CopyBits(securedIPdu_SduDataPtr, securedIPduAuthenticatorPosition, AuthenticatorPtr, 0,
130 authInfoTxLength);
131 USERCODE_DEBUG_PRINTDATA("TX AuthenticIPdu", authenticIPdu_SduDataPtr, authenticIPdu_ActualLength);
132 USERCODE_DEBUG_PRINTDATA("TX SecuredIPdu", securedIPdu_SduDataPtr, securedIPdu_SduLength);
133 }
134 /* End of part 2, i.e., end of the TX-related part of the DsBusCustomCode_onPduFeatureExecution function */
135
136 /* Part 3: If the secured IPDU is an RX IPDU, the Else part of the If-Else loop is executed. */
137 else
52
Bus Custom Code Interface Handling May 2024
Example of Implementing Secure Onboard Communication (SecOC) via the Bus Custom Code Interface
138 {
139 /* For details, see below. */
140 }
141
142 /* Return whether DsBusCustomCode_onPduFeatureExecution function is implemented correctly. */
143 return E_OK;
144 }
53
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
51
52 /* Check if a message linker is specified. If it is, first verify the message linker by calling the
53 * related demo user code function.
54 * If the user code function indicates an error, set the verification result to SECOC_MESSAGELINKERFAILURE.
55 * Then, exit DsBusCustomCode_onPduFeatureExecution with E_OK. */
56 if (messageLinkLength > 0 && authenticIPdu_ActualLength * 8 >= messageLinkLength)
57 {
58 Std_ReturnType result = UserCode_SecOCHelper_CompareBits(securedIPdu_SduDataPtr,
59 securedIPduMessageLinkerPosition, authenticIPdu_SduDataPtr, messageLinkPosition, messageLinkLength);
60 if (result != E_OK)
61 {
62 DSBUSCUSTOMCODE_TRY(featureDescriptor, DsBusCustomCodeSecOCRxPduFeature_setVerificationResult(
63 PduFeatureHandle, SECOC_MESSAGELINKERFAILURE));
64 USERCODE_DEBUG_PRINT("Verification aborted due to not matching message linker\n");
65 return E_OK;
66 }
67 }
68
69 /* Get whether a time stamp is used to calculate the freshness value.
70 * If the value of the related parameter is not set, set the value to FALSE, i.e., no time stamp is used.
71 * If a logical error occurs (e.g., an invalid handle), return E_NOT_OK and
72 * exit DsBusCustomCode_onPduFeatureExecution. */
73 {
74 boolean useFreshnessTimestamp;
75 returnValue = DsBusCustomCodeSecuredIPdu_getUseFreshnessTimestamp(securedIPdu_PduHandle,
76 &useFreshnessTimestamp);
77 if (returnValue == E_PARAMETER_NOT_SET)
78 {
79 useFreshnessTimestamp = FALSE;
80 }
81 else if (returnValue != E_OK)
82 {
83 return E_NOT_OK;
84 }
85
86 /* If a time stamp is used, call the related demo user code function to access the received
87 * freshness value and its length, and copy the values to local variables.
88 * Copying the data to local variables with defined data types avoids problems, e.g., if the freshness
89 * value manager specifies different data types for the accessed variables. */
90 uint32 freshnessVerifyValueLength = freshnessValueLength;
91 uint64 freshnessVerifyValue;
92 DSBUSCUSTOMCODE_TRY(featureDescriptor, UserCode_SecOC_GetRxFreshness(((struct UserCode_FeatureData*)
93 featureDataPtr)->TimeBaseHandle, 0, securedIPdu_SduDataPtr + (securedIPduFreshnessValuePosition / 8),
94 freshnessValueTxLength, 0, (uint8*)&freshnessVerifyValue, &freshnessVerifyValueLength,
95 useFreshnessTimestamp));
96 freshnessValue = freshnessVerifyValue;
97 }
98 USERCODE_DEBUG_PRINT("RX Local Freshness Value 0x%llX\n", freshnessValue);
99
100 /* Get whether a part of the payload of the authentic IPDU is included in the freshness value.
101 * If the value of the related parameter is not set, set the value to FALSE, i.e., no payload is included in
the
102 * freshness value.
103 * If a logical error occurs (e.g., an invalid handle), return E_NOT_OK and
104 * exit DsBusCustomCode_onPduFeatureExecution. */
105 returnValue = DsBusCustomCodeSecuredIPdu_getUseAuthDataFreshness(securedIPdu_PduHandle,
106 &useAuthDataFreshness);
107 if (returnValue == E_PARAMETER_NOT_SET)
108 {
109 useAuthDataFreshness = FALSE;
110 }
111 else if (returnValue != E_OK)
112 {
54
Bus Custom Code Interface Handling May 2024
Example of Implementing Secure Onboard Communication (SecOC) via the Bus Custom Code Interface
55
May 2024 Bus Custom Code Interface Handling
Examples of Implementing User-Specific Functionalities via the Bus Custom Code Interface
56
Bus Custom Code Interface Handling May 2024
API Reference of the Bus Custom Code Interface
57
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCodeHandle....................................................................... 58
The handle that represents a DsBusCustomCode element.
DsBusCustomCodeCommunicationClusterHandle.................................... 59
The handle that represents a communication cluster.
DsBusCustomCodeEcuHandle.................................................................. 60
The handle that represents an ECU.
DsBusCustomCodePduHandle................................................................. 60
The handle that represents a PDU.
DsBusCustomCodePduFeatureHandle...................................................... 61
The handle that represents a PDU feature.
DsBusCustomCodeSecOCPduFeatureHandle............................................ 62
The handle that represents a SecOC PDU feature.
DsBusCustomCodeSecOCRxPduFeatureHandle........................................ 64
The handle that represents a SecOC RX PDU feature.
DsBusCustomCodeSecOCTxPduFeatureHandle........................................ 66
The handle that represents a SecOC TX PDU feature.
DsBusCustomCodeSecuredIPduHandle.................................................... 68
The handle that represents a secured IPDU.
DsBusCustomCodeSignalHandle.............................................................. 70
The handle that represents a signal of a PDU.
DsBusCustomCodeUserCodePduFeatureHandle....................................... 71
The handle that represents the PDU User Code feature of a PDU.
DsBusCustomCodeUserPortHandle.......................................................... 72
The handle that represents a user port that is available for the PDU User
Code feature of a PDU.
DsBusCustomCodeHandle
58
Bus Custom Code Interface Handling May 2024
Handles of the Bus Custom Code Interface
Inheritance diagram
DsBusCustomCode
DsBusCustomCodeSecuredIPdu
DsBusCustomCodeSecOCPduFeature DsBusCustomCodeUserCodePduFeature
DsBusCustomCodeSecOCRxPduFeature DsBusCustomCodeSecOCTxPduFeature
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
DsBusCustomCodeCommunicationClusterHandle
Inheritance diagram
DsBusCustomCode
DsBusCustomCodeCommunicationCluster
Functions of the handle This handle does not provide handle-specific functions.
59
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
DsBusCustomCodeEcuHandle
Inheritance diagram
DsBusCustomCode
DsBusCustomCodeEcu
Functions of the handle This handle does not provide handle-specific functions.
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
DsBusCustomCodePduHandle
60
Bus Custom Code Interface Handling May 2024
Handles of the Bus Custom Code Interface
Inheritance diagram
DsBusCustomCode
DsBusCustomCodePdu
DsBusCustomCodeSecuredIPdu
Function Purpose
DsBusCustomCodePdu_getCanChannelName on page 81 To get the name of a CAN channel.
DsBusCustomCodePdu_getCanFrameTriggering on page 82 To get the frame triggering of a CAN frame or the CAN
identifier of a J1939‑compliant IPDU.
DsBusCustomCodePdu_getIsTx on page 85 To get the direction of a PDU.
DsBusCustomCodePdu_getLinFrameTriggering on page 86 To get the frame triggering of a LIN frame.
DsBusCustomCodePdu_getSduDataPtr on page 88 To get the SduDataPtr pointer of a PDU.
DsBusCustomCodePdu_getSduLength on page 89 To get the SDU length of a PDU in bytes.
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
DsBusCustomCodePduFeatureHandle
61
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Inheritance diagram
DsBusCustomCode
DsBusCustomCodePduFeature
DsBusCustomCodeSecOCPduFeature DsBusCustomCodeUserCodePduFeature
DsBusCustomCodeSecOCRxPduFeature DsBusCustomCodeSecOCTxPduFeature
Function Purpose
DsBusCustomCodePduFeature_getFeatureDataPtr on page 90 To get the FeatureDataPtr pointer of a PDU feature
handle.
DsBusCustomCodePduFeature_getPdu on page 91 To get the PDU that is accessed by a PDU feature handle.
DsBusCustomCodePduFeature_setFeatureDataPtr on page 93 To set the FeatureDataPtr pointer of a PDU feature
handle.
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
DsBusCustomCodeSecOCPduFeatureHandle
62
Bus Custom Code Interface Handling May 2024
Handles of the Bus Custom Code Interface
Inheritance diagram
DsBusCustomCode
DsBusCustomCodePduFeature
DsBusCustomCodeSecOCPduFeature
DsBusCustomCodeSecOCRxPduFeature DsBusCustomCodeSecOCTxPduFeature
Function Purpose
DsBusCustomCodeSecOCPduFeature_getAuthenticatorPositionOffset on To get the offset value of the position
page 94 of the authentication information in a
non-cryptographic secured IPDU.
DsBusCustomCodeSecOCPduFeature_getKeyAsString on page 96 To get the SecOC key of a secured IPDU
as a string value.
DsBusCustomCodeSecOCPduFeature_getKeyLength on page 97 To get the length of a SecOC key byte
array of a secured IPDU.
DsBusCustomCodeSecOCPduFeature_getKeyPtr on page 98 To get the KeyPtr pointer of a SecOC
PDU feature handle.
DsBusCustomCodeSecOCPduFeature_setAuthenticatorPositionOffset on To set an offset value to the position of
page 100 the authentication information in a non-
cryptographic secured IPDU.
DsBusCustomCodeSecOCPduFeature_setKeyLength on page 102 To set the length of a SecOC key byte
array of a secured IPDU.
DsBusCustomCodeSecOCPduFeature_setKeyPtr on page 103 To set the KeyPtr pointer of a SecOC
PDU feature handle.
Functions inherited from This handle inherits the following functions from
DsBusCustomCodePduFeature DsBusCustomCodePduFeatureHandle on page 61:
Handle
Function Purpose
DsBusCustomCodePduFeature_getFeatureDataPtr on page 90 To get the FeatureDataPtr pointer of a PDU feature
handle.
DsBusCustomCodePduFeature_getPdu on page 91 To get the PDU that is accessed by a PDU feature handle.
DsBusCustomCodePduFeature_setFeatureDataPtr on page 93 To set the FeatureDataPtr pointer of a PDU feature
handle.
63
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
DsBusCustomCodeSecOCRxPduFeatureHandle
Inheritance diagram
DsBusCustomCode
DsBusCustomCodePduFeature
DsBusCustomCodeSecOCPduFeature
DsBusCustomCodeSecOCRxPduFeature
Function Purpose
DsBusCustomCodeSecOCRxPduFeature_getCalculatedFreshnessValue on To get the data of the user code that is
page 105 provided to an RX secured IPDU via the
Calculated Freshness Value variable.
DsBusCustomCodeSecOCRxPduFeature_getEnableVerification on page 106 To get the enable state for verifying
the authentication information of an RX
secured IPDU.
DsBusCustomCodeSecOCRxPduFeature_getVerificationResult on page 108 To get data of the user code that is
provided to an RX secured IPDU via the
Verification Result variable.
DsBusCustomCodeSecOCRxPduFeature_setCalculatedFreshnessValue on To set data of the user code to an
page 109 RX secured IPDU via the Calculated
Freshness Value variable.
DsBusCustomCodeSecOCRxPduFeature_setVerificationResult on page 111 To set data of the user code to an
RX secured IPDU via the Verification
Result variable.
64
Bus Custom Code Interface Handling May 2024
Handles of the Bus Custom Code Interface
Functions inherited from This handle inherits the following functions from
DsBusCustomCodeSecOCPduF DsBusCustomCodeSecOCPduFeatureHandle on page 62:
eatureHandle
Function Purpose
DsBusCustomCodeSecOCPduFeature_getAuthenticatorPositionOffset on To get the offset value of the position
page 94 of the authentication information in a
non-cryptographic secured IPDU.
DsBusCustomCodeSecOCPduFeature_getKeyAsString on page 96 To get the SecOC key of a secured IPDU
as a string value.
DsBusCustomCodeSecOCPduFeature_getKeyLength on page 97 To get the length of a SecOC key byte
array of a secured IPDU.
DsBusCustomCodeSecOCPduFeature_getKeyPtr on page 98 To get the KeyPtr pointer of a SecOC
PDU feature handle.
DsBusCustomCodeSecOCPduFeature_setAuthenticatorPositionOffset on To set an offset value to the position of
page 100 the authentication information in a non-
cryptographic secured IPDU.
DsBusCustomCodeSecOCPduFeature_setKeyLength on page 102 To set the length of a SecOC key byte
array of a secured IPDU.
DsBusCustomCodeSecOCPduFeature_setKeyPtr on page 103 To set the KeyPtr pointer of a SecOC
PDU feature handle.
Functions inherited from This handle inherits the following functions from
DsBusCustomCodePduFeature DsBusCustomCodePduFeatureHandle on page 61:
Handle
Function Purpose
DsBusCustomCodePduFeature_getFeatureDataPtr on page 90 To get the FeatureDataPtr pointer of a PDU feature
handle.
DsBusCustomCodePduFeature_getPdu on page 91 To get the PDU that is accessed by a PDU feature handle.
DsBusCustomCodePduFeature_setFeatureDataPtr on page 93 To set the FeatureDataPtr pointer of a PDU feature
handle.
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
65
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCodeSecOCTxPduFeatureHandle
Inheritance diagram
DsBusCustomCode
DsBusCustomCodePduFeature
DsBusCustomCodeSecOCPduFeature
DsBusCustomCodeSecOCTxPduFeature
Function Purpose
DsBusCustomCodeSecOCTxPduFeature_getAuthenticationType on page 112 To get the enable state of the
authentication type manipulation
that is specified for a TX secured
IPDU.
DsBusCustomCodeSecOCTxPduFeature_getCalculatedFreshnessValue on page 114 To get the data of the user
code that is provided to a TX
secured IPDU via the Calculated
Freshness Value variable.
DsBusCustomCodeSecOCTxPduFeature_getEnableAuthentication on page 115 To get the enable state of the
authentication value calculation that
is specified for a TX secured IPDU.
DsBusCustomCodeSecOCTxPduFeature_getEnableFreshnessValueCalculation on To get the enable state of the
page 117 freshness value calculation that is
specified for a TX secured IPDU.
DsBusCustomCodeSecOCTxPduFeature_getFreshnessValueOffset on page 119 To get the offset value that is
specified for the freshness value of
a TX secured IPDU.
DsBusCustomCodeSecOCTxPduFeature_getUserDefinedAuthenticatorPtr on To get the pointer to the byte
page 120 array that provides the user-defined
authentication value, which is
specified for a TX secured IPDU.
DsBusCustomCodeSecOCTxPduFeature_getUserDefinedFreshnessValue on page 121 To get the user-defined freshness
value that is specified for a TX
secured IPDU.
DsBusCustomCodeSecOCTxPduFeature_setCalculatedFreshnessValue on page 123 To set data of the user code to a TX
secured IPDU via the Calculated
Freshness Value variable.
66
Bus Custom Code Interface Handling May 2024
Handles of the Bus Custom Code Interface
Functions inherited from This handle inherits the following functions from
DsBusCustomCodeSecOCPduF DsBusCustomCodeSecOCPduFeatureHandle on page 62:
eatureHandle
Function Purpose
DsBusCustomCodeSecOCPduFeature_getAuthenticatorPositionOffset on To get the offset value of the position
page 94 of the authentication information in a
non-cryptographic secured IPDU.
DsBusCustomCodeSecOCPduFeature_getKeyAsString on page 96 To get the SecOC key of a secured IPDU
as a string value.
DsBusCustomCodeSecOCPduFeature_getKeyLength on page 97 To get the length of a SecOC key byte
array of a secured IPDU.
DsBusCustomCodeSecOCPduFeature_getKeyPtr on page 98 To get the KeyPtr pointer of a SecOC
PDU feature handle.
DsBusCustomCodeSecOCPduFeature_setAuthenticatorPositionOffset on To set an offset value to the position of
page 100 the authentication information in a non-
cryptographic secured IPDU.
DsBusCustomCodeSecOCPduFeature_setKeyLength on page 102 To set the length of a SecOC key byte
array of a secured IPDU.
DsBusCustomCodeSecOCPduFeature_setKeyPtr on page 103 To set the KeyPtr pointer of a SecOC
PDU feature handle.
Functions inherited from This handle inherits the following functions from
DsBusCustomCodePduFeature DsBusCustomCodePduFeatureHandle on page 61:
Handle
Function Purpose
DsBusCustomCodePduFeature_getFeatureDataPtr on page 90 To get the FeatureDataPtr pointer of a PDU feature
handle.
DsBusCustomCodePduFeature_getPdu on page 91 To get the PDU that is accessed by a PDU feature handle.
DsBusCustomCodePduFeature_setFeatureDataPtr on page 93 To set the FeatureDataPtr pointer of a PDU feature
handle.
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
67
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCodeSecuredIPduHandle
Inheritance diagram
DsBusCustomCode
DsBusCustomCodePdu
DsBusCustomCodeSecuredIPdu
Function Purpose
DsBusCustomCodeSecuredIPdu_getAuthAlgorithmName on page 124 To get the value of the AUTOSAR
AuthAlgorithm attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthDataFreshnessLength on To get the value of the AUTOSAR
page 126 AuthDataFreshnessLength attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthDataFreshnessStartPosition To get the value of the AUTOSAR
on page 127 AuthDataFreshnessStartPosition attribute
of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthInfoTxLength on page 128 To get the value of the AUTOSAR
AuthInfoTxLength attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthPduHeaderLength on page 130 To get the value of the AUTOSAR
SecOCAuthPduHeaderLength attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthenticPdu on page 131 To get the authentic IPDU that is secured by a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthenticationBuildAttempts on To get the value of the AUTOSAR
page 132 AuthenticationBuildAttempts attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthenticationRetries on page 134 To get the value of the AUTOSAR
AuthenticationRetries attribute of a secured
IPDU.
DsBusCustomCodeSecuredIPdu_getDataId on page 135 To get the value of the AUTOSAR DataId
attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getFreshnessCounterSyncAttempts on To get the value of the AUTOSAR
page 136 FreshnessCounterSyncAttempts attribute of
a secured IPDU.
DsBusCustomCodeSecuredIPdu_getFreshnessTimestampPeriodFactor To get the value of the AUTOSAR
on page 138 FreshnessTimestampTimePeriodFactor
attribute of a secured IPDU.
68
Bus Custom Code Interface Handling May 2024
Handles of the Bus Custom Code Interface
Function Purpose
DsBusCustomCodeSecuredIPdu_getFreshnessValueId on page 139 To get the value of the AUTOSAR
FreshnessValueId attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getFreshnessValueLength on page 141 To get the value of the AUTOSAR
FreshnessValueLength attribute of a secured
IPDU.
DsBusCustomCodeSecuredIPdu_getFreshnessValueTxLength on To get the value of the AUTOSAR
page 142 FreshnessValueTxLength attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getKeyId on page 143 To get the value of the AUTOSAR KeyID attribute
of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getMessageLinkLength on page 144 To get the value of the AUTOSAR
MessageLinkLength attribute of a secured
IPDU.
DsBusCustomCodeSecuredIPdu_getMessageLinkPosition on page 146 To get the value of the AUTOSAR
MessageLinkPosition attribute of a secured
IPDU.
DsBusCustomCodeSecuredIPdu_getRxSecurityVerification on To get the value of the AUTOSAR
page 147 RxSecurityVerification attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getSecuredAreaLength on page 149 To get the value of the AUTOSAR
SecuredAreaLength attribute of a secured
IPDU.
DsBusCustomCodeSecuredIPdu_getSecuredAreaOffset on page 151 To get the value of the AUTOSAR
SecuredAreaOffset attribute of a secured
IPDU.
DsBusCustomCodeSecuredIPdu_getTimeStampRxAcceptanceWindow on To get the value of the AUTOSAR
page 152 TimestampRxAcceptanceWindow attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getUseAsCryptographicPdu on page 153 To get the value of the AUTOSAR
UseAsCryptographicIPdu attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getUseAuthDataFreshness on page 155 To get the value of the AUTOSAR
UseAuthDataFreshness attribute of a secured
IPDU.
DsBusCustomCodeSecuredIPdu_getUseFreshnessTimestamp on page 156 To get the value of the AUTOSAR
UseFreshnessTimestamp attribute of a secured
IPDU.
Functions inherited from This handle inherits the following functions from DsBusCustomCodePduHandle
DsBusCustomCodePduHandle on page 60:
Function Purpose
DsBusCustomCodePdu_getCanChannelName on page 81 To get the name of a CAN channel.
DsBusCustomCodePdu_getCanFrameTriggering on page 82 To get the frame triggering of a CAN frame or the CAN
identifier of a J1939‑compliant IPDU.
DsBusCustomCodePdu_getIsTx on page 85 To get the direction of a PDU.
DsBusCustomCodePdu_getLinFrameTriggering on page 86 To get the frame triggering of a LIN frame.
69
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Function Purpose
DsBusCustomCodePdu_getSduDataPtr on page 88 To get the SduDataPtr pointer of a PDU.
DsBusCustomCodePdu_getSduLength on page 89 To get the SDU length of a PDU in bytes.
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
DsBusCustomCodeSignalHandle
Inheritance diagram
DsBusCustomCode
DsBusCustomCodeSignal
Function Purpose
DsBusCustomCodeSignal_getEndianness on page 158 To get the endianness of a signal.
DsBusCustomCodeSignal_getLength on page 159 To get the length of a signal.
DsBusCustomCodeSignal_getStartBitPosition on page 160 To get the start bit position of a signal.
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
70
Bus Custom Code Interface Handling May 2024
Handles of the Bus Custom Code Interface
DsBusCustomCodeUserCodePduFeatureHandle
Purpose This handle represents the PDU User Code feature of a PDU.
Inheritance diagram
DsBusCustomCode
DsBusCustomCodePduFeature
DsBusCustomCodeUserCodePduFeature
Function Purpose
DsBusCustomCodeUserCodePduFeature_getNumberOfUserPorts on page 162 To get the number of user ports that are
specified for a PDU via the PDU User Code
feature.
DsBusCustomCodeUserCodePduFeature_getNumberOfUserSignals on page 163 To get the number of user signals that are
specified for a PDU via the PDU User Code
feature.
DsBusCustomCodeUserCodePduFeature_getResult on page 164 To get the data of the user code that is
provided to an RX PDU via the PDU User
Code feature.
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTriggering on To get the run‑time frame triggering of a
page 166 CAN frame or the run‑time CAN identifier
of a simulated RX J1939‑compliant IPDU
via the PDU User Code feature.
DsBusCustomCodeUserCodePduFeature_getUserPorts on page 168 To get the array of the user ports that are
specified for a PDU via the PDU User Code
feature.
DsBusCustomCodeUserCodePduFeature_getUserSignals on page 170 To get the array of the user signals that
are specified for a PDU via the PDU User
Code feature.
DsBusCustomCodeUserCodePduFeature_setResult on page 171 To set data of the user code to an RX PDU
via the PDU User Code feature.
71
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Functions inherited from This handle inherits the following functions from
DsBusCustomCodePduFeature DsBusCustomCodePduFeatureHandle on page 61:
Handle
Function Purpose
DsBusCustomCodePduFeature_getFeatureDataPtr on page 90 To get the FeatureDataPtr pointer of a PDU feature
handle.
DsBusCustomCodePduFeature_getPdu on page 91 To get the PDU that is accessed by a PDU feature handle.
DsBusCustomCodePduFeature_setFeatureDataPtr on page 93 To set the FeatureDataPtr pointer of a PDU feature
handle.
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
DsBusCustomCodeUserPortHandle
Purpose This handle represents a user port that is available for the PDU User Code feature
of a PDU.
Inheritance diagram
DsBusCustomCode
DsBusCustomCodeUserPort
Function Purpose
DsBusCustomCodeUserPort_getDirection on page 173 To get the direction of a user port that is available for the PDU User
Code feature of a PDU.
DsBusCustomCodeUserPort_getPortData on page 174 To get the data of a user port that is available for the PDU User Code
feature of a PDU.
DsBusCustomCodeUserPort_setPortData on page 176 To set data to a user port that is available for the PDU User Code
feature of a PDU.
72
Bus Custom Code Interface Handling May 2024
Handles of the Bus Custom Code Interface
Functions inherited from This handle inherits the following functions from DsBusCustomCodeHandle on
DsBusCustomCodeHandle page 58:
Function Purpose
DsBusCustomCode_getDescriptor on page 78 To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName on page 80 To get the name of an element that is addressed by a DsBusCustomCode
handle.
73
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCode_getDescriptor........................................................... 78
To get the descriptor of a DsBusCustomCode handle.
DsBusCustomCode_getName.................................................................. 80
To get the name of an element that is addressed by a DsBusCustomCode
handle.
DsBusCustomCodePdu_getCanChannelName......................................... 81
To get the name of a CAN channel.
DsBusCustomCodePdu_getCanFrameTriggering...................................... 82
To get the frame triggering of a CAN frame or the CAN identifier of a
J1939‑compliant IPDU.
DsBusCustomCodePdu_getIsTx................................................................ 85
To get the direction of a PDU.
DsBusCustomCodePdu_getLinFrameTriggering........................................ 86
To get the frame triggering of a LIN frame.
DsBusCustomCodePdu_getSduDataPtr.................................................... 88
To get the SduDataPtr pointer of a PDU.
DsBusCustomCodePdu_getSduLength..................................................... 89
To get the SDU length of a PDU in bytes.
DsBusCustomCodePduFeature_getFeatureDataPtr................................... 90
To get the FeatureDataPtr pointer of a PDU feature handle.
DsBusCustomCodePduFeature_getPdu.................................................... 91
To get the PDU that is accessed by a PDU feature handle.
DsBusCustomCodePduFeature_setFeatureDataPtr.................................... 93
To set the FeatureDataPtr pointer of a PDU feature handle.
DsBusCustomCodeSecOCPduFeature_getAuthenticatorPositionOff
set........................................................................................................... 94
To get the offset value of the position of the authentication information
in a non-cryptographic secured IPDU.
DsBusCustomCodeSecOCPduFeature_getKeyAsString............................. 96
To get the SecOC key of a secured IPDU as a string value.
DsBusCustomCodeSecOCPduFeature_getKeyLength............................... 97
To get the length of a SecOC key byte array of a secured IPDU.
DsBusCustomCodeSecOCPduFeature_getKeyPtr...................................... 98
To get the KeyPtr pointer of a SecOC PDU feature handle.
DsBusCustomCodeSecOCPduFeature_setAuthenticatorPositionOff
set......................................................................................................... 100
To set an offset value to the position of the authentication information in
a non-cryptographic secured IPDU.
74
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
DsBusCustomCodeSecOCPduFeature_setKeyLength.............................. 102
To set the length of a SecOC key byte array of a secured IPDU.
DsBusCustomCodeSecOCPduFeature_setKeyPtr.................................... 103
To set the KeyPtr pointer of a SecOC PDU feature handle.
DsBusCustomCodeSecOCRxPduFeature_getCalculatedFreshnessVa
lue......................................................................................................... 105
To get the data of the user code that is provided to an RX secured IPDU
via the Calculated Freshness Value variable.
DsBusCustomCodeSecOCRxPduFeature_getEnableVerification............... 106
To get the enable state for verifying the authentication information of an
RX secured IPDU.
DsBusCustomCodeSecOCRxPduFeature_getVerificationResult................ 108
To get data of the user code that is provided to an RX secured IPDU via
the Verification Result variable.
DsBusCustomCodeSecOCRxPduFeature_setCalculatedFreshnessVa
lue......................................................................................................... 109
To set data of the user code to an RX secured IPDU via the Calculated
Freshness Value variable.
DsBusCustomCodeSecOCRxPduFeature_setVerificationResult................ 111
To set data of the user code to an RX secured IPDU via the
Verification Result variable.
DsBusCustomCodeSecOCTxPduFeature_getAuthenticationType............. 112
To get the enable state of the authentication type manipulation that is
specified for a TX secured IPDU.
DsBusCustomCodeSecOCTxPduFeature_getCalculatedFreshnessVa
lue......................................................................................................... 114
To get the data of the user code that is provided to a TX secured IPDU via
the Calculated Freshness Value variable.
DsBusCustomCodeSecOCTxPduFeature_getEnableAuthentication......... 115
To get the enable state of the authentication value calculation that is
specified for a TX secured IPDU.
DsBusCustomCodeSecOCTxPduFeature_getEnableFreshnessValue
Calculation............................................................................................ 117
To get the enable state of the freshness value calculation that is specified
for a TX secured IPDU.
DsBusCustomCodeSecOCTxPduFeature_getFreshnessValueOffset.......... 119
To get the offset value that is specified for the freshness value of a TX
secured IPDU.
DsBusCustomCodeSecOCTxPduFeature_getUserDefinedAuthentic
atorPtr................................................................................................... 120
To get the pointer to the byte array that provides the user-defined
authentication value, which is specified for a TX secured IPDU.
75
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCodeSecOCTxPduFeature_getUserDefinedFreshness
Value..................................................................................................... 121
To get the user-defined freshness value that is specified for a TX secured
IPDU.
DsBusCustomCodeSecOCTxPduFeature_setCalculatedFreshnessVal
ue......................................................................................................... 123
To set data of the user code to a TX secured IPDU via the Calculated
Freshness Value variable.
DsBusCustomCodeSecuredIPdu_getAuthAlgorithmName...................... 124
To get the value of the AUTOSAR AuthAlgorithm attribute of a secured
IPDU.
DsBusCustomCodeSecuredIPdu_getAuthDataFreshnessLength.............. 126
To get the value of the AUTOSAR AuthDataFreshnessLength attribute
of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthDataFreshnessStartPositio
n........................................................................................................... 127
To get the value of the AUTOSAR AuthDataFreshnessStartPosition
attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthInfoTxLength........................... 128
To get the value of the AUTOSAR AuthInfoTxLength attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthPduHeaderLength................... 130
To get the value of the AUTOSAR SecOCAuthPduHeaderLength
attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthenticPdu................................. 131
To get the authentic IPDU that is secured by a secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthenticationBuildAttempts.......... 132
To get the value of the AUTOSAR AuthenticationBuildAttempts
attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getAuthenticationRetries..................... 134
To get the value of the AUTOSAR AuthenticationRetries attribute of
a secured IPDU.
DsBusCustomCodeSecuredIPdu_getDataId............................................ 135
To get the value of the AUTOSAR DataId attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getFreshnessCounterSyncAttemp
ts........................................................................................................... 136
To get the value of the AUTOSAR FreshnessCounterSyncAttempts
attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getFreshnessTimestampPeriodFac
tor......................................................................................................... 138
To get the value of the AUTOSAR
FreshnessTimestampTimePeriodFactor attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getFreshnessValueId............................. 139
To get the value of the AUTOSAR FreshnessValueId attribute of a
secured IPDU.
76
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
DsBusCustomCodeSecuredIPdu_getFreshnessValueLength..................... 141
To get the value of the AUTOSAR FreshnessValueLength attribute of
a secured IPDU.
DsBusCustomCodeSecuredIPdu_getFreshnessValueTxLength................. 142
To get the value of the AUTOSAR FreshnessValueTxLength attribute
of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getKeyId.............................................. 143
To get the value of the AUTOSAR KeyID attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getMessageLinkLength........................ 144
To get the value of the AUTOSAR MessageLinkLength attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getMessageLinkPosition....................... 146
To get the value of the AUTOSAR MessageLinkPosition attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getRxSecurityVerification...................... 147
To get the value of the AUTOSAR RxSecurityVerification attribute
of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getSecuredAreaLength........................ 149
To get the value of the AUTOSAR SecuredAreaLength attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getSecuredAreaOffset.......................... 151
To get the value of the AUTOSAR SecuredAreaOffset attribute of a
secured IPDU.
DsBusCustomCodeSecuredIPdu_getTimeStampRxAcceptanceWin
dow...................................................................................................... 152
To get the value of the AUTOSAR TimestampRxAcceptanceWindow
attribute of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getUseAsCryptographicPdu................. 153
To get the value of the AUTOSAR UseAsCryptographicIPdu attribute
of a secured IPDU.
DsBusCustomCodeSecuredIPdu_getUseAuthDataFreshness................... 155
To get the value of the AUTOSAR UseAuthDataFreshness attribute of
a secured IPDU.
DsBusCustomCodeSecuredIPdu_getUseFreshnessTimestamp................. 156
To get the value of the AUTOSAR UseFreshnessTimestamp attribute of
a secured IPDU.
DsBusCustomCodeSignal_getEndianness............................................... 158
To get the endianness of a signal.
DsBusCustomCodeSignal_getLength..................................................... 159
To get the length of a signal.
DsBusCustomCodeSignal_getStartBitPosition......................................... 160
To get the start bit position of a signal.
77
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCodeUserCodePduFeature_getNumberOfUserPorts.......... 162
To get the number of user ports that are specified for a PDU via the PDU
User Code feature.
DsBusCustomCodeUserCodePduFeature_getNumberOfUserSignal
s............................................................................................................ 163
To get the number of user signals that are specified for a PDU via the
PDU User Code feature.
DsBusCustomCodeUserCodePduFeature_getResult................................ 164
To get the data of the user code that is provided to an RX PDU via the
PDU User Code feature.
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTri
ggering................................................................................................. 166
To get the run‑time frame triggering of a CAN frame or the run‑time
CAN identifier of a simulated RX J1939‑compliant IPDU via the PDU User
Code feature.
DsBusCustomCodeUserCodePduFeature_getUserPorts.......................... 168
To get the array of the user ports that are specified for a PDU via the PDU
User Code feature.
DsBusCustomCodeUserCodePduFeature_getUserSignals....................... 170
To get the array of the user signals that are specified for a PDU via the
PDU User Code feature.
DsBusCustomCodeUserCodePduFeature_setResult................................ 171
To set data of the user code to an RX PDU via the PDU User Code
feature.
DsBusCustomCodeUserPort_getDirection.............................................. 173
To get the direction of a user port that is available for the PDU User Code
feature of a PDU.
DsBusCustomCodeUserPort_getPortData............................................... 174
To get the data of a user port that is available for the PDU User Code
feature of a PDU.
DsBusCustomCodeUserPort_setPortData............................................... 176
To set data to a user port that is available for the PDU User Code feature
of a PDU.
DsBusCustomCode_getDescriptor
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
78
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCode_getDescriptor(DsBusCustomCodeHandle Handle, char** Descriptor)
Parameter Description
Handle A DsBusCustomCode handle.
Descriptor The descriptor of the handle.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // Declare a pointer for the descriptor
2 char* featureDescriptor;
3 // Let the pointer point to the descriptor
79
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCode_getName
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCode_getName(DsBusCustomCodeHandle Handle, char** Name)
Parameter Description
Handle A DsBusCustomCode handle.
Name The name of the element that is addressed by the DsBusCustomCode
handle.
80
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // Declare pointer for name
2 char* name;
3 // Let the pointer point to the name
4 DsBusCustomCode_getName(PduFeatureHandle, &name);
DsBusCustomCodePdu_getCanChannelName
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodePdu_getCanChannelName(DsBusCustomCodePduHandle PduHandle, char** Name)
81
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
Name The name of the CAN channel.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // Declare pointer for CAN channel name
2 char* My_CanChannelName;
3
4 // Let the pointer point to the CAN channel name
5 DsBusCustomCodePdu_getCanChannelName(pduHandle, &My_CanChannelName);
DsBusCustomCodePdu_getCanFrameTriggering
Purpose To get the frame triggering of a CAN frame or the CAN identifier of a
J1939‑compliant IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
82
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
However, this function gets only the CAN frame identifier or the CAN identifier
that is specified in the communication matrix:
§ If the communication matrix specifies an RX mask for the frame triggering, the
CAN frame identifier that is available on the bus for the accessed PDU might
differ from the CAN frame identifier that is specified in the communication
matrix. In this case, this function does not provide the CAN frame identifier
that is available on the bus.
§ If the CAN identifier of a J1939‑compliant IPDU changes at run time, e.g.,
because the related network node has claimed a new transport protocol
address, this function does not provide the changed identifier.
Tip
To get the data that is actually available on the bus at run time, you can use
the DsBusCustomCodePdu_getRuntimeCanFrameTriggering function
instead. However, this is possible only if you use the Bus Manager. Refer to
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTrigger
ing on page 166.
Syntax
Std_ReturnType DsBusCustomCodePdu_getCanFrameTriggering(DsBusCustomCodePduHandle PduHandle,
DsBusCustomCodeCanFrameTriggeringType* DsBusCustomCodeCanFrameTriggering)
83
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
DsBusCustomCodeCanFrameTriggering A struct of three elements providing the
following information:
§ (.Identifier): Providing the CAN
frame identifier or the CAN identifier of
J1939‑compliant IPDUs.
§ (.AddresingMode): Providing the
identifier format:
§ Standard = standard identifier format
(11-bit)
§ Extended = extended identifier format
(29-bit)
§ (.FrameBehavior): Providing the CAN
frame type:
§ Can20 = classic CAN frame
§ CanFd = CAN FD frame
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // Declare CAN frame triggering variables (frame identifier, identifier format, frame type)
2 DsBusCustomCodeCanFrameTriggeringType My_CanFrameTriggering;
3 uint32 My_ID;
4 uint8 My_AddressingMode;
5 uint8 My_FrameBehavior;
6 ...
7 // Let the pointer point to the CAN frame triggering structure and extract frame triggering variables
8 DsBusCustomCodePdu_getCanFrameTriggering(pduHandle, &My_CanFrameTriggering);
9 My_ID = (uint32)My_CanFrameTriggering.Identifier;
10 My_AddressingMode = (uint8)My_CanFrameTriggering.AddresingMode;
11 My_FrameBehavior = (uint8)My_CanFrameTriggering.FrameBehavior;
84
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
DsBusCustomCodePdu_getIsTx
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the direction of a PDU, i.e, whether a PDU is transmitted (TX
PDU) or received (RX PDU).
Syntax
Std_ReturnType DsBusCustomCodePdu_getIsTx(DsBusCustomCodePduHandle PduHandle, boolean* IsTx)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
IsTx The direction of the PDU:
§ TRUE: TX PDU
§ FALSE: RX PDU
85
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodePdu_getLinFrameTriggering
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the following information on the frame triggering of a LIN
frame:
§ LIN frame identifier (ID), which is part of the protected identifier (PID) of the
LIN frame header
§ Checksum type, i.e., classic or enhanced checksum calculation type
To get the frame triggering, this function has to access a PDU that is included
in the related frame. However, this function can get the frame triggering only if
the accessed PDU is included in exactly one LIN frame, i.e., there is only one LIN
frame triggering.
Syntax
Std_ReturnType DsBusCustomCodePdu_getLinFrameTriggering(DsBusCustomCodePduHandle PduHandle,
DsBusCustomCodeLinFrameTriggeringType* DsBusCustomCodeLinFrameTriggering)
86
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
DsBusCustomCodeLinFrameTriggering A struct of two elements providing the LIN
frame triggering:
§ (.Identifier): Providing the LIN frame
identifier.
§ (.ChecksumType): Providing the
checksum type:
§ Classic = classic checksum calculation
type
§ Enhanced = enhanced checksum
calculation type
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // Declare LIN frame triggering variables (frame identifier, checksum type)
2 DsBusCustomCodeLinFrameTriggeringType My_LinFrameTriggering;
3 uint32 My_ID;
4 uint8 My_ChecksumType;
5 ...
6 // Let the pointer point to the LIN frame triggering structure and extract frame triggering variables
7 DsBusCustomCodePdu_getLinFrameTriggering(pduHandle, &My_LinFrameTriggering);
8 My_ID = (uint32)My_LinFrameTriggering.Identifier;
9 My_ChecksumType = (uint8)My_LinFrameTriggering.ChecksumType;
87
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCodePdu_getSduDataPtr
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the SduDataPtr pointer of a PDU. The pointer points to the
SDU bytes, i.e., the data bytes of the PDU.
Syntax
Std_ReturnType DsBusCustomCodePdu_getSduDataPtr(DsBusCustomCodePduHandle PduHandle, uint8** SduDataPtr)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
SduDataPtr The pointer to the SDU bytes.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
88
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Value Description
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodePdu_getSduLength
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the SDU length, i.e., the payload length of a PDU in bytes.
Syntax
Std_ReturnType DsBusCustomCodePdu_getSduLength(DsBusCustomCodePduHandle PduHandle, uint32* SduLength)
89
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
SduLength The SDU length in bytes.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodePduFeature_getFeatureDataPtr
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
In the user code, you can let the pointer point to an arbitrary, user-defined data
structure, e.g., a struct. By using this function, you can access the data of this
data structure.
For example, you use the data structure to store data that alternates during
subsequent PDU feature execution calls, such as counter values or state
90
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
information. In this case, you can use this function to access the data that was
written to the data structure during the previous PDU feature execution call.
Syntax
Std_ReturnType DsBusCustomCodePduFeature_getFeatureDataPtr(DsBusCustomCodePduFeatureHandle PduFeatureHandle, uint8**
FeatureDataPtr)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
FeatureDataPtr The FeatureDataPtr pointer of the PDU feature handle. The
data type of the pointer is uint8. However, in the user code you
can cast this data type to the data type of the data structure to
which the pointer points.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodePduFeature_getPdu
91
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the PDU that is accessed by a PDU feature handle. The
function gets the PDU via its PDU handle.
Syntax
Std_ReturnType DsBusCustomCodePduFeature_getPdu(DsBusCustomCodePduFeatureHandle PduFeatureHandle,
DsBusCustomCodePduHandle* PduHandle)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
PduHandle The PDU handle that addresses the PDU which is accessed by the
PDU feature handle.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
92
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Example -
DsBusCustomCodePduFeature_setFeatureDataPtr
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function sets the FeatureDataPtr pointer of a PDU feature handle.
In the user code, you can let the pointer point to an arbitrary,
user-defined data structure, e.g., a struct. When you set the
FeatureDataPtr pointer by using this function during the initialization
phase of an executable application (i.e., real-time application or
offline simulation application), you can access the data of the data
structure by calling the DsBusCustomCodePduFeature_getFeatureDataPtr
function during PDU feature execution calls. Refer to
DsBusCustomCodePduFeature_getFeatureDataPtr on page 90.
For example, you can use a user-defined data structure to store data that
alternates during different feature execution calls such as counter values and
state information. By using the FeatureDataPtr pointer, you can provide this
alternating data to the user code.
Syntax
Std_ReturnType DsBusCustomCodePduFeature_setFeatureDataPtr(DsBusCustomCodePduFeatureHandle PduFeatureHandle, uint8*
FeatureDataPtr)
93
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
FeatureDataPtr The FeatureDataPtr pointer of the PDU feature handle. The
data type of the pointer is uint8. However, in the user code you
can cast this data type to the data type of the data structure to
which the pointer points.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCPduFeature_getAuthenticatorPositionOffset
Purpose To get the offset value of the position of the authentication information in a
non-cryptographic secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
94
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Description This function gets the offset value of the position of the authentication
information (i.e., the freshness value and the authenticator) in a non-
cryptographic secured IPDU. The offset value indicates the deviation in
bits of the current position of the authentication information from
the position that is specified in the communication matrix. If the
offset value is 0, there is no deviation and the current position of
the authentication information is the position that is specified in the
communication matrix. You can specify a user-defined offset value by using the
DsBusCustomCodeSecOCPduFeature_setAuthenticatorPositionOffset
function. Refer to
DsBusCustomCodeSecOCPduFeature_setAuthenticatorPositionOffset
on page 100.
Syntax
Std_ReturnType DsBusCustomCodeSecOCPduFeature_getAuthenticatorPositionOffset(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, sint32* AuthenticatorPositionOffset)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
AuthenticatorPositionOffset The deviation in bits of the current position of the
authentication information in the secured IPDU from
the position that is specified in the communication
matrix.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
95
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Example -
DsBusCustomCodeSecOCPduFeature_getKeyAsString
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function can get the SecOC key of a secured IPDU as a string value. To
get the SecOC key, it must be specified in the communication matrix. The
implementation of the SecOC key in the communication matrix is customer-
specific.
Syntax
Std_ReturnType DsBusCustomCodeSecOCPduFeature_getKeyAsString(DsBusCustomCodePduFeatureHandle PduFeatureHandle, char**
KeyAsString)
96
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
KeyAsString The SecOC key that is specified in the communication matrix. The
key is provided as a string value.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCPduFeature_getKeyLength
Purpose To get the length of a SecOC key byte array of a secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
97
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Description This function gets the length of a SecOC key byte array of a
secured IPDU. To get the length, it must be set beforehand by using
the DsBusCustomCodeSecOCPduFeature_setKeyLength function. Refer to
DsBusCustomCodeSecOCPduFeature_setKeyLength on page 102.
Syntax
Std_ReturnType DsBusCustomCodeSecOCPduFeature_getKeyLength(DsBusCustomCodePduFeatureHandle PduFeatureHandle, uint32*
KeyLength)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
KeyLength The length of the SecOC key byte array in bytes.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCPduFeature_getKeyPtr
98
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the KeyPtr pointer of a SecOC PDU feature
handle. To get the pointer, it must be set beforehand by using
the DsBusCustomCodeSecOCPduFeature_setKeyPtr function. Refer to
DsBusCustomCodeSecOCPduFeature_setKeyPtr on page 103.
For example, you can use the KeyPtr pointer to access the SecOC key of a
secured IPDU: In the user code, you can specify a byte array that contains the
SecOC key of a secured IPDU and let the pointer point to this array. By using this
function, you can access the data of this array during subsequent PDU feature
execution calls.
Syntax
Std_ReturnType DsBusCustomCodeSecOCPduFeature_getKeyPtr(DsBusCustomCodePduFeatureHandle PduFeatureHandle, uint8** KeyPtr)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
KeyPtr The KeyPtr pointer of the SecOC PDU feature handle. The data
type of the pointer is uint8. However, in the user code you can
cast this data type to the data type of the byte array to which the
pointer points.
99
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCPduFeature_setAuthenticatorPositionOffset
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient Bus implementation software (only for internal use)
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function sets an offset value to the position of the authentication
information in a non-cryptographic secured IPDU, i.e., in a secured IPDU whose
UseAsCryptographicIPdu attribute is unspecified or set to False.
For example, you can use this function to specify the position of the
authentication information if the secured IPDU has a dynamic payload length.
To get the payload length in the current PDU feature execution call (i.e., the
100
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
The bus implementation software internally uses the specified offset value to
determine the start position of the authentication information in the secured
IPDU, e.g., for inspecting the truncated freshness and authenticator values of a
received secured IPDU.
The specified offset value applies only to the current PDU feature execution call:
The bus implementation software resets the offset value to 0 before the next
PDU feature execution call (i.e., before the next sampling step).
At run time, you can access the offset value by using the
DsBusCustomCodeSecOCPduFeature_getAuthenticatorPositionOffset
function. Refer to
DsBusCustomCodeSecOCPduFeature_getAuthenticatorPositionOffset
on page 94.
Syntax
Std_ReturnType DsBusCustomCodeSecOCPduFeature_setAuthenticatorPositionOffset(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, sint32 AuthenticatorPositionOffset)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
AuthenticatorPositionOffset The offset value in bits that applies to the position of
the authentication information that it is specified in
the communication matrix for a non-cryptographic
secured IPDU.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
101
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Example -
DsBusCustomCodeSecOCPduFeature_setKeyLength
Purpose To set the length of a SecOC key byte array of a secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function sets the length of a SecOC key byte array of a secured IPDU.
In the user code, you can use a byte array to store the SecOC key of the
secured IPDU. The SecOC key can directly be specified in the user code.
The SecOC key can also be specified in the communication matrix but this
requires a customer-specific implementation of the SecOC key. Depending on
the customer-specific implementation, you can get the SecOC key by using
the DsBusCustomCodeSecOCPduFeature_getKeyAsString function. Refer to
DsBusCustomCodeSecOCPduFeature_getKeyAsString on page 96.
At run time, you can access the length of the SecOC key byte array by using
the DsBusCustomCodeSecOCPduFeature_getKeyLength function. Refer to
DsBusCustomCodeSecOCPduFeature_getKeyLength on page 97.
Syntax
Std_ReturnType DsBusCustomCodeSecOCPduFeature_setKeyLength(DsBusCustomCodePduFeatureHandle PduFeatureHandle, uint32
KeyLength)
102
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
KeyLength The length of the SecOC key byte array in bytes.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCPduFeature_setKeyPtr
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function sets the KeyPtr pointer of the SecOC PDU feature handle.
For example, you can use the KeyPtr pointer to access the SecOC key
of a secured IPDU: In the user code, you can specify a byte array that
103
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
contains the SecOC key of a secured IPDU and let the pointer point to this
array. When you set the KeyPtr pointer by using this function during the
initialization phase of an executable application (i.e., real-time application or
offline simulation application), you can access the data of the array by calling the
DsBusCustomCodeSecOCPduFeature_getKeyPtr function during PDU feature
execution calls. Refer to DsBusCustomCodeSecOCPduFeature_getKeyPtr on
page 98.
Syntax
Std_ReturnType DsBusCustomCodeSecOCPduFeature_setKeyPtr(DsBusCustomCodePduFeatureHandle PduFeatureHandle, uint8* KeyPtr)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
KeyPtr The KeyPtr pointer of the SecOC PDU feature handle. The data
type of the pointer is uint8. However, in the user code you can
cast this data type to the data type of the byte array the pointer
points to.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
104
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
DsBusCustomCodeSecOCRxPduFeature_getCalculatedFreshnessValue
Purpose To get the data of the user code that is provided to an RX secured IPDU via the
Calculated Freshness Value variable.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the data of the user code that is provided to an RX secured
IPDU via the Calculated Freshness Value variable.
Syntax
Std_ReturnType DsBusCustomCodeSecOCRxPduFeature_getCalculatedFreshnessValue(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, uint64* CalculatedFreshnessValue)
105
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
CalculatedFreshnessValue The data that is provided to the Calculated
Freshness Value variable by the user code.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCRxPduFeature_getEnableVerification
Purpose To get the enable state for verifying the authentication information of an RX
secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value provided by
bus implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the enable state for verifying the authentication information of
an RX secured IPDU.
In the user code, you can use the provided state value to enable or disable
the verification of the authentication information of the RX secured IPDU. The
specifications in the user code determine how the state value is evaluated.
106
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Syntax
Std_ReturnType DsBusCustomCodeSecOCRxPduFeature_getEnableVerification(DsBusCustomCodePduFeatureHandle PduFeatureHandle,
uint32* EnableVerification)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
EnableVerification The enable state of the authentication information verification
that is provided by bus implementation software.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
107
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCodeSecOCRxPduFeature_getVerificationResult
Purpose To get data of the user code that is provided to an RX secured IPDU via the
Verification Result variable.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the data of the user code that is provided to an RX secured
IPDU via the Verification Result variable.
Syntax
Std_ReturnType DsBusCustomCodeSecOCRxPduFeature_getVerificationResult(DsBusCustomCodePduFeatureHandle PduFeatureHandle,
uint32* VerificationResult)
108
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
VerificationResult The data that is provided to the Verification Result
variable by the user code.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCRxPduFeature_setCalculatedFreshnessValue
Purpose To set data of the user code to an RX secured IPDU via the Calculated
Freshness Value variable.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient Bus implementation software, provides data via TRC and/or
model variable
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function sets data of the user code to an RX secured IPDU via the
Calculated Freshness Value variable.
The specifications in the user code determine which data is set to the
Calculated Freshness Value variable. For example, you can use this
function to set the freshness value that was calculated for the RX secured IPDU in
the user code by using user-specific algorithms.
109
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Syntax
Std_ReturnType DsBusCustomCodeSecOCRxPduFeature_setCalculatedFreshnessValue(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, uint64 CalculatedFreshnessValue)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
CalculatedFreshnessValues The data that is provided to the Calculated
Freshness Value variable by the user code.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
110
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
DsBusCustomCodeSecOCRxPduFeature_setVerificationResult
Purpose To set data of the user code to an RX secured IPDU via the Verification
Result variable.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient Bus implementation software, provides data via TRC and/or
model variable
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function sets data of the user code to an RX secured IPDU via the
Verification Result variable.
The specifications in the user code determine which data is set to the
Verification Result variable. For example, you can use this function to set
the verification result that was calculated for the RX secured IPDU in the user
code by using user-specific algorithms.
If you do this, the specifications in the user code determine which verification
results can be available and by which value they are represented. To ensure full
compatibility with all bus implementation software tools, it is recommended to
use the following mapping of verification results and values:
111
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Syntax
Std_ReturnType DsBusCustomCodeSecOCRxPduFeature_setVerificationResult(DsBusCustomCodePduFeatureHandle PduFeatureHandle,
uint32 VerificationResult)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
VerificationResult The data that is provided to the Verification Result
variable by the user code.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCTxPduFeature_getAuthenticationType
Purpose To get the enable state of the authentication type manipulation that is specified
for a TX secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
112
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter data source TRC and/or model variable, or constant value provided by
bus implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the enable state of the authentication type manipulation that
is specified for a TX secured IPDU.
In the user code, you can use the provided state value to enable or disable
the manipulation of the authentication type of the TX secured IPDU. The
specifications in the user code determine how the state value is evaluated.
To ensure full compatibility with all bus implementation software tools, it is
recommended to use the following values:
Syntax
Std_ReturnType DsBusCustomCodeSecOCTxPduFeature_getAuthenticationType(DsBusCustomCodePduFeatureHandle PduFeatureHandle,
uint32* AuthenticationType)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
AuthenticationType The enable state of the authentication type manipulation that is
provided by bus implementation software.
113
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCTxPduFeature_getCalculatedFreshnessValue
Purpose To get the data of the user code that is provided to a TX secured IPDU via the
Calculated Freshness Value variable.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the data of the user code that is provided to a TX secured
IPDU via the Calculated Freshness Value variable.
Syntax
Std_ReturnType DsBusCustomCodeSecOCTxPduFeature_getCalculatedFreshnessValue(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, uint64* CalculatedFreshnessValue)
114
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
CalculatedFreshnessValue The data that is provided to the Calculated
Freshness Value variable by the user code.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCTxPduFeature_getEnableAuthentication
Purpose To get the enable state of the authentication value calculation that is specified
for a TX secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value provided by
bus implementation software
Parameter data recipient User code
115
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the enable state of the authentication value calculation that is
specified for a TX secured IPDU.
In the user code, you can use the provided state value to enable or disable the
calculation of the authentication value of the TX secured IPDU. The specifications
in the user code determine how the state value is evaluated. To ensure full
compatibility with all bus implementation software tools, it is recommended to
use the following values:
Syntax
Std_ReturnType DsBusCustomCodeSecOCTxPduFeature_getEnableAuthentication(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, uint32* EnableAuthentication)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
EnableAuthentication The enable state of the authentication value calculation that
is provided by bus implementation software.
116
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCTxPduFeature_getEnableFreshnessValueCalculation
Purpose To get the enable state of the freshness value calculation that is specified for a TX
secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value provided by
bus implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the enable state of the freshness value calculation that is
specified for a TX secured IPDU.
In the user code, you can use the provided state value to enable or disable the
calculation of the freshness value of the TX secured IPDU. The specifications
in the user code determine how the state value is evaluated. To ensure full
compatibility with all bus implementation software tools, it is recommended to
use the following values:
117
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Syntax
Std_ReturnType DsBusCustomCodeSecOCTxPduFeature_getEnableFreshnessValueCalculation(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, uint32* EnableFreshnessValueCalculation)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
EnableFreshnessValueCalculation The enable state of the freshness value
calculation that is provided by bus
implementation software.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
118
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
DsBusCustomCodeSecOCTxPduFeature_getFreshnessValueOffset
Purpose To get the offset value that is specified for the freshness value of a TX secured
IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value provided by
bus implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the offset value that is specified for the freshness value of a TX
secured IPDU.
The specified value applies to the freshness value of the TX secured IPDU,
regardless of whether the freshness value is calculated in the user code or a
user-defined freshness value is used. The specified offset can be a positive or
negative value, or 0.
Syntax
Std_ReturnType DsBusCustomCodeSecOCTxPduFeature_getFreshnessValueOffset(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, sint64* FreshnessValueOffset)
119
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
FreshnessValueOffset The offset value that applies to the freshness value and which
is provided by bus implementation software.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCTxPduFeature_getUserDefinedAuthenticatorPtr
Purpose To get the pointer to the byte array that provides the user-defined authentication
value, which is specified for a TX secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value provided by
bus implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the pointer to the byte array that provides the user-defined
authentication value, which is specified for a TX secured IPDU.
120
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
DsBusCustomCodeSecOCTxPduFeature_getEnableAuthentication on
page 115.
Syntax
Std_ReturnType DsBusCustomCodeSecOCTxPduFeature_getUserDefinedAuthenticatorPtr(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, uint8** UserDefinedAuthenticatorPtr)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
UserDefinedAuthenticatorPtr The pointer to the byte array that provides the user-
defined authentication value.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCTxPduFeature_getUserDefinedFreshnessValue
Purpose To get the user-defined freshness value that is specified for a TX secured IPDU.
121
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value provided by
bus implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the user-defined freshness value that is specified for a TX
secured IPDU.
Syntax
Std_ReturnType DsBusCustomCodeSecOCTxPduFeature_getUserDefinedFreshnessValue(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, uint64* UserDefinedFreshnessValue)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
UserDefinedFreshnessValue The user-defined freshness value that is provided by
bus implementation software.
122
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecOCTxPduFeature_setCalculatedFreshnessValue
Purpose To set data of the user code to a TX secured IPDU via the Calculated
Freshness Value variable.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient Bus implementation software, provides data via TRC and/or
model variable
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function sets data of the user code to a TX secured IPDU via the
Calculated Freshness Value variable.
The specifications in the user code determine which data is set to the
Calculated Freshness Value variable. For example, you can use this
function to set the freshness value that was calculated for the TX secured IPDU in
the user code by using user-specific algorithms.
123
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Syntax
Std_ReturnType DsBusCustomCodeSecOCTxPduFeature_setCalculatedFreshnessValue(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, uint64 CalculatedFreshnessValue)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
CalculatedFreshnessValues The data that is provided to the Calculated
Freshness Value variable by the user code.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getAuthAlgorithmName
Purpose To get the value of the AUTOSAR AuthAlgorithm attribute of a secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
124
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR AuthAlgorithm attribute of a
secured IPDU.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getAuthAlgorithmName(DsBusCustomCodePduHandle PduHandle, char**
AuthAlgorithmNameAsString)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
AuthAlgorithmNameAsString The name of the authentication algorithm.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
125
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCodeSecuredIPdu_getAuthDataFreshnessLength
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getAuthDataFreshnessLength(DsBusCustomCodePduHandle PduHandle, uint16*
AuthDataFreshnessLength)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
AuthDataFreshnessLength The length in bits of the authentic IPDU's payload that is
included in the freshness value.
126
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getAuthDataFreshnessStartPosition
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getAuthDataFreshnessStartPosition(DsBusCustomCodePduHandle PduHandle, uint16*
AuthDataFreshnessStartPosition)
127
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
AuthDataFreshnessStartPosition The position of the first bit in the authentic
IPDU's payload that is included in the freshness
value.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getAuthInfoTxLength
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
128
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR AuthInfoTxLength attribute of a
secured IPDU.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getAuthInfoTxLength(DsBusCustomCodePduHandle PduHandle, uint32*
AuthInfoTxLength)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
AuthInfoTxLength The length in bits of the calculated authenticator that is included
in the payload of the secured IPDU.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
129
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Example
1 // Copy authInfoTxLength number of bits of authenticator to secured IPDU
2 uint32 authInfoTxLength;
3 DsBusCustomCodeSecuredIPdu_getAuthInfoTxLength(securedIPdu_PduHandle, &authInfoTxLength);
DsBusCustomCodeSecuredIPdu_getAuthPduHeaderLength
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getAuthPduHeaderLength(DsBusCustomCodePduHandle PduHandle, uint8*
AuthPduHeaderLength)
130
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
AuthPduHeaderLength The length in bytes of the secured PDU header that is used in
the secured IPDU.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getAuthenticPdu
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the authentic IPDU that is secured by a secured IPDU. The
function gets the authentic IPDU via its handle.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getAuthenticPdu(DsBusCustomCodePduHandle PduHandle, DsBusCustomCodePduHandle*
AuthenticPduHandle)
131
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
AuthenticPduHandle The handle of the authentic IPDU that is secured by the secured
IPDU.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // The PduFeatureHandle is typically provided as a parameter of an interface
2 // call, e.g. DsBusCustomCode_onApplicationInit
3 DsBusCustomCodePduHandle securedIPdu_PduHandle, authenticIPdu_PduHandle;
4 DsBusCustomCodePduFeature_getPdu(PduFeatureHandle, &securedIPdu_PduHandle);
5 DsBusCustomCodeSecuredIPdu_getAuthenticPdu(securedIPdu_PduHandle, &authenticIPdu_PduHandle);
6
DsBusCustomCodeSecuredIPdu_getAuthenticationBuildAttempts
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
132
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getAuthenticationBuildAttempts(DsBusCustomCodePduHandle PduHandle, uint16*
AuthenticationBuildAttempts)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
AuthenticationBuildAttempts The number of the authentication build attempts.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
133
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Example -
DsBusCustomCodeSecuredIPdu_getAuthenticationRetries
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getAuthenticationRetries(DsBusCustomCodePduHandle PduHandle, uint16*
AuthenticationRetries)
134
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
AuthenticationRetries The number of the additional authentication attempts.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getDataId
Purpose To get the value of the AUTOSAR DataId attribute of a secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR DataId attribute of a secured
IPDU.
135
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getDataId(DsBusCustomCodePduHandle PduHandle, uint16* DataId)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
DataId The data ID of the secured IPDU.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 DsBusCustomCodePduHandle securedIPdu_PduHandle;
2 DsBusCustomCodePduFeature_getPdu(PduFeatureHandle, &securedIPdu_PduHandle);
3 DsBusCustomCodeSecuredIPdu_getDataId(securedIPdu_PduHandle, &dataId);
4 // ... prepare authentication data including data ID and generate MAC
5
DsBusCustomCodeSecuredIPdu_getFreshnessCounterSyncAttempts
136
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getFreshnessCounterSyncAttempts(DsBusCustomCodePduHandle PduHandle, uint32*
FreshnessCounterSyncAttempts)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
FreshnessCounterSyncAttempts The number of the additional synchronization
attempts for the freshness counter.
137
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getFreshnessTimestampPeriodFactor
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getFreshnessTimestampPeriodFactor(DsBusCustomCodePduHandle PduHandle, uint32*
FreshnessTimestampPeriodFactor)
138
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
FreshnessTimestampPeriodFactor The factor in microseconds of the time period
for the freshness time stamp.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getFreshnessValueId
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
139
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR FreshnessValueId attribute of a
secured IPDU.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getFreshnessValueId(DsBusCustomCodePduHandle PduHandle, uint16*
FreshnessValueId)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
FreshnessValueId The freshness value ID of the secured IPDU.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
140
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
DsBusCustomCodeSecuredIPdu_getFreshnessValueLength
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR FreshnessValueLength attribute
of a secured IPDU.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getFreshnessValueLength(DsBusCustomCodePduHandle PduHandle, uint32*
FreshnessValueLength)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
FreshnessValueLength The length of the complete freshness value in bits.
141
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getFreshnessValueTxLength
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getFreshnessValueTxLength(DsBusCustomCodePduHandle PduHandle, uint32*
FreshnessValueTxLength)
142
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
FreshnessValueTxLength The length in bits of the freshness value that is included in
the payload of the secured IPDU.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getKeyId
Purpose To get the value of the AUTOSAR KeyID attribute of a secured IPDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR KeyID attribute of a secured IPDU.
143
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
According to AUTOSAR, the KeyID attribute identifies the key that is used to
generate and verify the message authentication code (MAC). The specified key ID
value must be unique per ECU.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getKeyId(DsBusCustomCodePduHandle PduHandle, uint32* KeyId)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
KeyId The key ID.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getMessageLinkLength
144
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR MessageLinkLength attribute of a
secured IPDU.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getMessageLinkLength(DsBusCustomCodePduHandle PduHandle, uint16*
MessageLinkLength)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
MessageLinkLength The length of the message linker in bits.
145
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getMessageLinkPosition
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR MessageLinkPosition attribute
of a secured IPDU.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getMessageLinkPosition(DsBusCustomCodePduHandle PduHandle, uint16*
MessageLinkPos)
146
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
MessageLinkPos The position of the first bit in the authentic IPDU's payload that is
used as the message linker.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getRxSecurityVerification
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
147
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Note
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getRxSecurityVerification(DsBusCustomCodePduHandle PduHandle, boolean*
RxSecurityVerification)
148
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
RxSecurityVerification The value determining whether the authentication
information of a secured IPDU is verified on the receiver
side:
§ TRUE: The authentication information is verified.
§ FALSE: The authentication information is not verified.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getSecuredAreaLength
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR SecuredAreaLength attribute of a
secured IPDU.
149
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getSecuredAreaLength(DsBusCustomCodePduHandle PduHandle, uint32*
SecuredAreaLength)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
SecuredAreaLength The length in bytes of the authentic IPDU's payload that is
secured.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
150
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
DsBusCustomCodeSecuredIPdu_getSecuredAreaOffset
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR SecuredAreaOffset attribute of a
secured IPDU.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getSecuredAreaOffset(DsBusCustomCodePduHandle PduHandle, uint32*
SecuredAreaOffset)
151
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
AuthPduHeaderLength The position of the first byte in the authentic IPDU's payload
that is secured.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getTimeStampRxAcceptanceWindow
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
152
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getTimeStampRxAcceptanceWindow(DsBusCustomCodePduHandle PduHandle, uint64*
TimeStampRxAcceptanceWindow)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
TimeStampRxAcceptanceWindow The maximum allowed deviation in milliseconds of
a received freshness time stamp from the expected
freshness time stamp.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getUseAsCryptographicPdu
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
153
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getUseAsCryptographicPdu(DsBusCustomCodePduHandle PduHandle, boolean*
UseAsCryptographicIPdu)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
UseAsCryptographicIPdu The value determining whether the secured IPDU is used as
cryptographic IPDU:
§ TRUE: The secured IPDU is used as cryptographic IPDU.
§ FALSE: The secured IPDU is not used as cryptographic
IPDU.
154
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getUseAuthDataFreshness
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the value of the AUTOSAR UseAuthDataFreshness attribute
of a secured IPDU.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getUseAuthDataFreshness(DsBusCustomCodePduHandle PduHandle, boolean*
UseAuthDataFreshness)
155
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
UseAuthDataFreshness The value determining whether a part of the payload of an
authentic IPDU is included in the freshness value:
§ TRUE: A part of the payload of an authentic IPDU is
included in the freshness value.
§ FALSE: No part of the payload of an authentic IPDU is
included in the freshness value.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSecuredIPdu_getUseFreshnessTimestamp
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
156
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSecuredIPdu_getUseFreshnessTimestamp(DsBusCustomCodePduHandle PduHandle, boolean*
UseFreshnessTimestamp)
Parameter Description
PduHandle A DsBusCustomCode PDU handle.
UseFreshnessTimestamp The value determining whether a freshness time stamp or a
freshness counter is used to generate the freshness value:
§ TRUE: A freshness time stamp is used.
§ FALSE: A freshness counter is used.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
157
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Example -
DsBusCustomCodeSignal_getEndianness
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Syntax
Std_ReturnType DsBusCustomCodeSignal_getEndianness(DsBusCustomCodeSignalHandle Handle, DsBusCustomCode_ByteOrderType*
Data)
158
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Parameter Description
Handle A DsBusCustomCode handle.
Data The endianness of the signal. It can be one of the following enumeration
values:
§ BigEndian: The most significant byte of the signal is stored first and the
most significant bit is the start bit.
§ LittleEndian: The least significant byte of the signal is stored first and
the least significant bit is the start bit.
§ Opaque: The byte order is similar to the little endian format.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSignal_getLength
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
159
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Syntax
Std_ReturnType DsBusCustomCodeSignal_getLength(DsBusCustomCodeSignalHandle Handle, uint32* Data)
Parameter Description
Handle A DsBusCustomCode handle.
Data The signal length in bits.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeSignal_getStartBitPosition
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Communication matrix (via bus implementation software)
Parameter data recipient User code
160
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the start bit position of a signal in bits. The start bit position
determines the first bit in the payload of a PDU that is used by the signal.
Syntax
Std_ReturnType DsBusCustomCodeSignal_getStartBitPosition(DsBusCustomCodeSignalHandle Handle, uint32* Data)
Parameter Description
Handle A DsBusCustomCode handle.
Data The start bit position of the signal in bits.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
161
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCodeUserCodePduFeature_getNumberOfUserPorts
Purpose To get the number of user ports that are specified for a PDU via the PDU User
Code feature.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value set by bus
implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the number of user ports that are specified for a PDU via
the PDU User Code feature. The PDU User Code feature is a feature of bus
implementation software tools. For more information on the feature, refer to the
documentation of the related bus implementation software tool.
Syntax
Std_ReturnType DsBusCustomCodeUserCodePduFeature_getNumberOfUserPorts(DsBusCustomCodePduFeatureHandle PduFeatureHandle,
uint32* Data)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
Data The number of the user ports.
162
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // Declare a uint32 variable for the number of user ports
2 uint32 UserPortCount;
3
4 // Get the number of user ports and provide it to the UserPortCount variable
5 DsBusCustomCodeUserCodePduFeature_getNumberOfUserPorts(PduFeatureHandle, &UserPortCount);
DsBusCustomCodeUserCodePduFeature_getNumberOfUserSignals
Purpose To get the number of user signals that are specified for a PDU via the PDU User
Code feature.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value set by bus
implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the number of user signals that are specified for a PDU via
the PDU User Code feature. The PDU User Code feature is a feature of bus
implementation software tools. For more information on the feature, refer to the
documentation of the related bus implementation software tool.
Syntax
Std_ReturnType DsBusCustomCodeUserCodePduFeature_getNumberOfUserSignals(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, uint32* Data)
163
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
Data The number of user signals.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeUserCodePduFeature_getResult
Purpose To get the data of the user code that is provided to an RX PDU via the PDU User
Code feature.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient User code
164
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the data of the user code that is provided to an RX PDU
via the PDU User Code feature. The PDU User Code feature is a feature of bus
implementation software tools. For more information on the feature, refer to the
documentation of the related bus implementation software tool.
Syntax
Std_ReturnType DsBusCustomCodeUserCodePduFeature_getResult(DsBusCustomCodePduFeatureHandle PduFeatureHandle, uint32*
Data)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
Data The data that is provided by the user code.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
165
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTriggering
Purpose To get the run‑time frame triggering of a CAN frame or the run‑time CAN
identifier of a simulated RX J1939‑compliant IPDU via the PDU User Code
feature.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source Run‑time data received on the bus (provided by bus
implementation software)
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Note
In most cases, the data that is available on the bus and that is accessed by this
function is the same data as specified in the communication matrix. However, in
some cases, the data might differ. For example:
§ The communication matrix specifies an RX mask for the frame triggering of
a CAN frame. In this case, the CAN frame identifier that is available on the
bus for the accessed PDU might differ from the CAN frame identifier that is
specified in the communication matrix.
166
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Note
The requirements for implementing this function in the user code differ
depending on the specific use scenario. Refer to Implementing the
DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTriggering
Function in the User Code on page 26.
Tip
Syntax
Std_ReturnType DsBusCustomCodeUserCodePduFeature_getRuntimeCanFrameTriggering(DsBusCustomCodePduFeatureHandle
PduFeatureHandle, DsBusCustomCodeRuntimeCanFrameTriggeringType* DsBusCustomCodeRuntimeCanFrameTriggering)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
DsBusCustomCodeRuntimeCanFrameTriggering A struct of four elements providing the following information:
§ (.Identifier): Providing the CAN frame identifier or the CAN identifier
of J1939‑compliant IPDUs.
§ (.AddressingMode): Providing the identifier format:
§ Standard = standard identifier format (11-bit)
§ Extended = extended identifier format (29-bit)
167
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
§ (.FrameBehavior): Providing the CAN frame type:
§ Can20 = classic CAN frame
§ CanFd = CAN FD frame
§ (.BitRateSwitch): Providing the bit rate switch:
§ NotSet: The bit rate switch is not specified.
§ Disabled: The bit rate switch is disabled, i.e., the data phase of the
CAN FD frame is transmitted with the same bit rate as the arbitration
phase of the frame.
§ Enabled: The bit rate switch is enabled, i.e., the data phase of the
CAN FD frame can be transmitted with a higher bit rate than the
arbitration phase of the frame.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
DsBusCustomCodeUserCodePduFeature_getUserPorts
Purpose To get the array of the user ports that are specified for a PDU via the PDU User
Code feature.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value set by bus
implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
168
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Description This function gets the array of the user ports that are specified for a PDU via
the PDU User Code feature. The PDU User Code feature is a feature of bus
implementation software tools. For more information on the feature, refer to the
documentation of the related bus implementation software tool.
The array size is determined by the number of user ports that are specified
for the PDU User Code feature. You can get the array size by using the
DsBusCustomCodeUserCodePduFeature_getNumberOfUserPorts function.
Refer to DsBusCustomCodeUserCodePduFeature_getNumberOfUserPorts
on page 162.
The array provides access to the configured user ports, i.e., to the
direction and the data of the user ports. You can access the direction
and the data by using the DsBusCustomCodeUserPort_getDirection,
DsBusCustomCodeUserPort_setPortData, and
DsBusCustomCodeUserPort_getPortData functions. Refer to
DsBusCustomCodeUserPort_getDirection on page 173,
DsBusCustomCodeUserPort_setPortData on page 176, and
DsBusCustomCodeUserPort_getPortData on page 174, respectively.
Syntax
Std_ReturnType DsBusCustomCodeUserCodePduFeature_getUserPorts(DsBusCustomCodePduFeatureHandle PduFeatureHandle,
DsBusCustomCodeUserPortHandle** Data)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
Data The pointer to get the array. To get the array, the pointer points to
the user port handle of the first user port of the array.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
169
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Value Description
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // Declare a pointer for the UserPorts array of handles
2 DsBusCustomCodeUserPortHandle* UserPorts;
3
4 // Let the pointer point to the array of handles
5 DsBusCustomCodeUserCodePduFeature_getUserPorts(PduFeatureHandle, &UserPorts);
DsBusCustomCodeUserCodePduFeature_getUserSignals
Purpose To get the array of the user signals that are specified for a PDU via the PDU User
Code feature.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value set by bus
implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the array of the user signals that are specified for a PDU via
the PDU User Code feature. The PDU User Code feature is a feature of bus
implementation software tools. For more information on the feature, refer to the
documentation of the related bus implementation software tool.
The array size is determined by the number of user signals that are specified
via the PDU User Code feature. You can get the array size by using
the DsBusCustomCodeUserCodePduFeature_getNumberOfUserSignals
function. Refer to
DsBusCustomCodeUserCodePduFeature_getNumberOfUserSignals on
page 163.
The array provides access to the configured user signals, i.e., to the ISignals that
are mapped to user signals via the PDU User Code feature. If a user signal is not
mapped to an ISignal, the array entries of this user signal are NULL.
170
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
You can use this function to provide the data of the user signals to the user
code. In the user code, you can use the data to verify received checksum values
or calculate counter values, for example.
Syntax
Std_ReturnType DsBusCustomCodeUserCodePduFeature_getUserSignals(DsBusCustomCodePduFeatureHandle PduFeatureHandle,
DsBusCustomCodeSignalHandle** Data)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
Data The pointer to get the array. To get the array, the pointer points to
the signal handle of the first user signal of the array.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeUserCodePduFeature_setResult
Purpose To set data of the user code to an RX PDU via the PDU User Code feature.
171
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient Bus implementation software, provides data via TRC and/or
model variable
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function sets data of the user code to an RX PDU via the PDU User Code
feature. The PDU User Code feature is a feature of bus implementation software
tools. For more information on the feature, refer to the documentation of the
related bus implementation software tool.
The specifications in the user code determine which data is set to the RX
PDU. For example, you can use this function to set the verification result of a
checksum value that was received with the PDU and evaluated in the user code.
At run time, you can also access the data by using the
DsBusCustomCodeUserCodePduFeature_getResult function. Refer to
DsBusCustomCodeUserCodePduFeature_getResult on page 164.
Syntax
Std_ReturnType DsBusCustomCodeUserCodePduFeature_setResult(DsBusCustomCodePduFeatureHandle PduFeatureHandle, uint32 Data)
Parameter Description
PduFeatureHandle A DsBusCustomCode PDU feature handle.
Data The data that is provided by the user code.
172
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example -
DsBusCustomCodeUserPort_getDirection
Purpose To get the direction of a user port that is available for the PDU User Code feature
of a PDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source TRC and/or model variable, or constant value set by bus
implementation software
Parameter data recipient User code
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the direction of a user port that is available for the PDU
User Code feature of a PDU. The PDU User Code feature is a feature of bus
implementation software tools. For more information on the feature, refer to the
documentation of the related bus implementation software tool.
Syntax
Std_ReturnType DsBusCustomCodeUserPort_getDirection(DsBusCustomCodeUserPortHandle UserPortHandle, boolean* Data)
173
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Parameter Description
UserPortHandle A DsBusCustomCode user port handle.
Data The direction of the user port that is addressed by user port handle:
§ TRUE: The direction of the user port is Out.
§ FALSE: The direction of the user port is In.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // Declare a boolean variable for the direction of an user port
2 boolean portIsOut;
3
4 // Get the direction of the first user port of the UserPorts array and provide the direction to the portIsOut variable
5 DsBusCustomCodeUserPort_getDirection(UserPorts[0], &portIsOut);
DsBusCustomCodeUserPort_getPortData
Purpose To get the data of a user port that is available for the PDU User Code feature of a
PDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
174
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function gets the data of a user port that is available for the PDU User Code
feature of a PDU. The PDU User Code feature is a feature of bus implementation
software tools. For more information on the feature, refer to the documentation
of the related bus implementation software tool.
You can use this function to get data of user inports or of user outports.
However, in most cases, using this function is useful only to get data of user
inports, for example, to provide data that is received from a behavior model to
the user code.
If you want to use this function to get the data of a user outport, you must set
the data beforehand by using the DsBusCustomCodeUserPort_setPortData
function. Refer to DsBusCustomCodeUserPort_setPortData on page 176.
Syntax
Std_ReturnType DsBusCustomCodeUserPort_getPortData(DsBusCustomCodeUserPortHandle UserPortHandle, float64* Data)
Parameter Description
UserPortHandle A DsBusCustomCode user port handle.
Data The user port data that is accessed by the user port handle.
175
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_PARAMETER_NOT_SET The requested information is not available.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // Declare a float64 variable for the user port data
2 float64 port3Data;
3
4 // Get the data of the third user port of the UserPorts array and provide the data to the port3Data variable
5 DsBusCustomCodeUserPort_getPortData(UserPorts[2], &port3Data);
DsBusCustomCodeUserPort_setPortData
Purpose To set data to a user port that is available for the PDU User Code feature of a
PDU.
Parameter data The following table provides an overview of the required data source of the
function parameters and the recipients of the parameter data. When the
function is called at run time but the data source does not provide the required
data, the function returns E_PARAMETER_NOT_SET.
Parameter data source User code
Parameter data recipient Bus implementation software, provides data via TRC and/or
model variable
For an overview of the bus implementation software tools with which this
function can be used, refer to Using Bus Custom Code Functions with Bus
Implementation Software on page 23.
Description This function sets data of the user code to a user port that is available for the
PDU User Code feature of a PDU. The PDU User Code feature is a feature of bus
implementation software tools. For more information on the feature, refer to the
documentation of the related bus implementation software tool.
The specifications in the user code determine which data is set to the user port.
For example, you can use this function to write status information to a user
outport. Then, the model variable of the user outport can provide this data to a
behavior model, for example.
176
Bus Custom Code Interface Handling May 2024
Functions of the Bus Custom Code Interface
You can use this function to set data to user outports or to user inports.
However, in most cases, using this function is useful only to set data to user
outports.
Syntax
Std_ReturnType DsBusCustomCodeUserPort_setPortData(DsBusCustomCodeUserPortHandle UserPortHandle, float64 Data)
Parameter Description
UserPortHandle A DsBusCustomCode user port handle.
Data The data that is provided by the user code.
Value Description
E_OK The function is correctly executed.
E_NOT_OK The function is not correctly executed.
E_INVALID_HANDLE A handle is invalid, e.g., because of an assigned NULL pointer.
Example
1 // Declare the port4Data variable for the user port data and specify the data of the variable
2 float64 port4Data = 12.04;
3
4 // Write the data of the port4Data variable to the fourth user port of the UserPorts array
5 DsBusCustomCodeUserPort_setPortData(UserPorts[3], port4Data);
177
May 2024 Bus Custom Code Interface Handling
API Reference of the Bus Custom Code Interface
178
Bus Custom Code Interface Handling May 2024
Index
Index
B
Bus Custom Code interface 10
functions 20
handles 12, 20
modules 12
return values 13
run-time behavior 15
syntax of functions 13
bus implementation software 10
C
Common Program Data folder 8
D
Documents folder 8
DsBusCustomCode module 12
F
function syntax of the Bus Custom Code
interface 13
functions of the Bus Custom Code interface 20
H
handles of the Bus Custom Code interface 12,
20
L
Local Program Data folder 8
M
modules of the Bus Custom Code interface 12
P
PduUserCode module 12
R
return values of the Bus Custom Code
interface 13
run-time behavior 15
S
SecOC module 12
U
user code 10
run-time behavior 15
179
May 2024 Bus Custom Code Interface Handling
Index
180
Bus Custom Code Interface Handling May 2024