XCP Module User-Guide
XCP Module User-Guide
The Xcp module require interfaces from several other AUTOSAR modules, and provides some interfaces also. In this
confluence we’ll list these interfaces and how to use them for anyone who wishes to integrate this module in any stack.
First let’s take a general look at this main function. Basically, it is used as a stub for testing the Xcp functionality. The
Xcp module is a layer built on top of the transport layer. Our module supports CAN and Ethernet communication
protocols. However, we weren’t provided any communication stack; so we couldn’t test the module on CAN protocol.
So, in order to be able to test this module, we need a workaround. So, we used socket communication but we
encapsulated in CAN interfaces. In other words, the Xcp module only sees CanIf interfaces (transmit & receive), but
these interfaces are really implemented in sockets; and the maximum data length of any used packet is 8 bytes. We’ll
see everything in details in the following sections, as we describe every function in this figure below.
1) Xcp Interface:
- As we know every AUTOSAR module needs a
configuration file to be linked with the static
code.
- “Xcp.h” & “Xcp.c” are the static code.
- To be more specific, the Xcp module needs exactly two interfaces from the OS.
- To make our module easy to integrate, we referred to the OS SWS to get the exact APIs provided by the AUTOSAR OS.
Then, we implemented these functions by ourselves in “Os.h” & “Os.c”.
1. Counter:
- The Xcp module needs a counter that increments every 1ms, it’s called Xcp_counter.
- According to the OS SWS, these three APIs are provided by the OS.
2. Scheduled functions:
- We invented a function called create_timer(). We use it to call our periodic functions every certain amounts of time.
We use POSIX timers. This function takes 3 parameters:
* period of scheduled function in ms.
* pointer to scheduled function
* pointer to integer value passed to the scheduled
function.
3) CAN Interface:
- As mentioned in the introduction, the module supports CAN communication protocol. However, we weren’t provided
any communication stack, so we need a workaround. We used sockets to simulate the CAN protocol.
1. Connect:
- Xcp_CanIfConnect() connects to a socket
and returns the socket ID. It’s different
from its CAN counterpart, but we needed
it.
2. Receive:
- We receive packets using sockets, then we pack it in a PduInfoPtr, then we
call CanIfRxIndication() with the new PduInfoPtr; as if the CAN bus received a
pdu and called this function with the received Pdu. So from the point of view
of the Xcp module, it has received a pdu from the CAN bus.
- CanIfRxIndication() calls
Xcp_RxIndication() which is the function
that is handles received packets in the
Xcp module.
NB:
CanIfRxIndication(), TriggerTransmit(),TxConfirmation() are the APIs specified by the AUTOSAR SWS for CAN.
4) Memory Interface:
- In this interface, given that we weren’t provided
any memory stack, we used POSIX shared
memory, and we accessed addresses directly.
- If we wanted to read the variable placed in our memory segment, we simply dereference the pointer holding the
address (i.e. no memory interface).
Ex: here we have the address reserved in ent->XcpOdtEntryAddress. To get the value stored in this address, we cast
this address to a pointer then we dereference it.
NB: This pointer here points to a 4byte variable, but in other functions, it can point to a 1byte variable.
- If we wanted to write to the variable placed in our memory segment, we simply dereference the pointer holding the
address (i.e. no memory interface) and put the value.
Ex: here we have the address reserved in odt->XcpOdtEntry->XcpOdtEntryAddress. To write a value places in
received_Stim_data to this address, we cast this address to a pointer then we dereference it and we put the value.
NB: This pointer here points to a 4byte variable, but in other functions, it can point to a 1byte variable.