Introduction
In AUTOSAR Classic, communication between software components is vital for building complex automotive systems. AUTOSAR provides various interfaces to facilitate communication and the two fundamental ones are AUTOSAR Sender-Receiver or Client-Server interfaces. Each interface type has distinct characteristics and attributes that make them suitable for different scenarios. In this article, we will present each interface and explore when it is appropriate to use Client/Server or Sender/Receiver communication in AUTOSAR-based systems.
Understanding Sender/Receiver and Client/Server
AUTOSAR interfaces act as gateways for requesting and providing information between software components. Let’s briefly examine the key aspects of each interface type:
Sender/Receiver Interface
The Sender/Receiver Interface enables the exchange of data elements between components. Data elements work as global variables that store values. This interface type is suitable for scenarios where components need to share data asynchronously, without direct synchronization requirements. A sender component provides the data and one or multiple receiver components access it when they need it.
Additionally, to manage the communication, AUTOSAR offers various attributes. For instance, a sender component can notify the RTE that it cannot provide a validate data, or it can request acknowledgement feedback when it transmits a data. On the other hand, a receiver component can check things like whether the data has changed before processing it. It could also check the data status to determine whether it’s invalid, outdated or if any general errors occurred when the RTE has conveyed the data.
Client/Server Interface
The Client/Server Interface defines operations implemented by server components, which can be invoked by one or more client components. It resembles a function call mechanism, where clients request services from the server. We distinguish three typical types of operations:
- Get operation: The “Get” communication allows the server to provide information to the client. It is implemented with an output argument in the server’s operation.
- Set operation: The “Set” communication enables the client to push information to the server. It is implemented with an input argument in the server’s operation.
- Bi-directional operation: In bi-directional communication, the client can retrieve information, process it, and set a result. In this case, the server operation has both input and output arguments.
Additionally, AUTOSAR offers attributes to manage the communication. For instance, the operation call can be either synchronous or asynchronous. In synchronous communication, the client is blocked and waits for the server’s response. In asynchronous communication, the client can continue its execution and trigger a callback once the server’s response is ready. Both types can have a timeout attribute to handle delayed or unresponsive servers. Moreover, since multiple clients can call a single server, the server can define a “Queuelength” attribute that specifies the maximum number of requests to be buffered. If the queue exceeds this limit, the RTE returns a timeout error.
When is it suitable to use Sender/Receiver or Client/Server communication?
Use cases for Sender/Receiver communication:
Asynchronous Data Exchange: When components need to exchange data asynchronously, with no strict synchronization requirements, Sender/Receiver communication is appropriate. This interface is suitable for scenarios where the receiver may not immediately access the transmitted data.
Low Latency: If low-latency communication is crucial, Sender/Receiver communication is a good choice. The receiver component can directly access the data without waiting for a request or response, resulting in faster data access.
Simple Data Exchange: When the communication primarily involves straightforward data exchange between components, Sender/Receiver communication provides a lightweight solution. It is suitable for scenarios where the communication requirements are minimal, and the focus is on efficient data sharing.
Use cases for Client/Server communication:
Service-Oriented Architecture: When the system follows a service-oriented architecture, where server components provide specific services to clients, Client/Server communication is suitable. This interface type enables a clear separation of responsibilities and encapsulation of functionality within server components.
Complex Operations: If the desired functionality involves complex operations that require multiple inputs and outputs, Client/Server communication provides a structured approach. The server component implements the operation, and clients can invoke it with the necessary parameters, receiving results in return.
Resource Sharing: When multiple client components need to share and access a common resource or functionality provided by a server component, Client/Server communication is appropriate. It allows for efficient utilization of the server’s capabilities by multiple clients.
Scalability: Client/Server communication supports scalability as multiple clients can request services from a single server. This makes it suitable for systems that require handling an increasing number of clients and distributing the workload effectively.
Conclusion
Choosing the appropriate communication interface, whether it is Client/Server or Sender/Receiver, is crucial for designing effective AUTOSAR-based systems. The Sender/Receiver interface is suitable for asynchronous data exchange, low-latency requirements, and simple data sharing scenarios. On the other hand, the Client/Server interface is ideal for service-oriented architectures, complex operations, resource sharing, and scalability. By considering the specific requirements, synchronization needs, and architectural considerations of the system, developers can make an informed decision on which communication interface best fits their AUTOSAR-based project, ensuring efficient and reliable communication between software components.