Skip to content

Commit 7966c19

Browse files
Document CAN message size handling (#288)
* Document CAN message size handling Signed-off-by: Konrad Breitsprecher <Konrad.Breitsprecher@vector.com>
1 parent bd48e51 commit 7966c19

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

docs/api/services/can.rst

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ CAN controllers will only communicate within the same network.
6767
Sending CAN Frames
6868
~~~~~~~~~~~~~~~~~~
6969

70-
Data is transferred in the form of a |CanFrame| and received as a |CanFrameEvent|. To send a |CanFrame|, it must be setup
71-
with a CAN ID and the data to be transmitted. Furthermore, valid |CanFrameFlag| have to be set::
70+
Data is transferred in the form of a |CanFrame| and received as a |CanFrameEvent|.
71+
To send a |CanFrame|, it must be set up with a CAN ID and the data to be transmitted.
72+
Furthermore, valid |CanFrameFlag| must be set.
73+
The |CanFrame| struct allows any payload size via its dataField member, messages that exceed CAN/CAN FD limits are
74+
passed through unchanged.
75+
The following snippet shows how to send a CAN FD frame::
7276

7377
// Prepare a CAN message with id 0x17
7478
CanFrame canFrame;
@@ -91,14 +95,14 @@ To be notified of the success or failure of the transmission, a ``FrameTransmitH
9195
};
9296
canController->AddFrameTransmitHandler(frameTransmitHandler);
9397

94-
An optional second parameter of |AddFrameTransmitHandler| allows to specify the status (|Transmitted|, ...) of the
98+
An optional second parameter of |AddFrameTransmitHandler| allows specifying the status (|Transmitted|, ...) of the
9599
|CanFrameTransmitEvent| to be received. By default, each status is enabled.
96100

97101
.. admonition:: Note
98102

99103
In a simple simulation without the network simulator, the |CanTransmitStatus| of the |CanFrameTransmitEvent| will
100104
always be |Transmitted|. If a detailed simulation is used, it is possible that the transmit queue overflows
101-
causing the handler to be called with |TransmitQueueFull| signaling a transmission failure.
105+
which causes the handler to be called with |TransmitQueueFull|, signaling a transmission failure.
102106

103107
Receiving CAN Frame Events
104108
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -112,8 +116,9 @@ frame, a timestamp and the actual |CanFrame|. The handler is called whenever a |
112116
};
113117
canController->AddFrameHandler(frameHandler);
114118

115-
An optional second parameter of |AddFrameHandler| allows to specify the direction (TX, RX, TX/RX) of the CAN frames to be
116-
received. By default, only frames of RX direction are handled.
119+
An optional second parameter of |AddFrameHandler| allows specifying the direction (TX, RX, TX/RX) of the CAN frames to
120+
be received.
121+
By default, only frames of RX direction are handled.
117122

118123
Receiving State Change Events
119124
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -137,16 +142,18 @@ Then, the controller must be started explicitly by calling |Start|. Now the cont
137142
Additional control commands are |Stop| and |Reset|.
138143

139144
The following example configures a CAN controller with a baud rate of 10'000 baud for regular CAN messages and a baud
140-
rate of 1'000'000 baud for CAN |_| FD messages and 1'000'000 baud for CAN |_| XL, respectively. Then, the controller is started::
145+
rate of 1'000'000 baud for CAN |_| FD messages and 1'000'000 baud for CAN |_| XL, respectively. Then, the controller
146+
is started::
141147

142148
canController->SetBaudRate(10000, 1000000, 1000000);
143149
canController->Start();
144150

145151
.. admonition:: Note
146152

147-
Both |SetBaudRate| and |Start| should not be called earlier than in the lifecycle service's
148-
:cpp:func:`communication ready handler<SilKit::Core::synd::ILifecycleService::SetCommunicationReadyHandler()>`. Otherwise, it is not guaranteed
149-
that all participants are already connected, which can cause the call to have no effect.
153+
Both |SetBaudRate| and |Start| should be called in the lifecycle service's
154+
:cpp:func:`communication ready handler<SilKit::Core::synd::ILifecycleService::SetCommunicationReadyHandler()>`.
155+
Otherwise, it is not guaranteed that all participants are already connected, which can cause the call to have no
156+
effect.
150157

151158
Managing the Event Handlers
152159
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -189,9 +196,11 @@ Enumerations and Typedefs
189196
Usage Examples
190197
--------------
191198

192-
This section contains complete examples that show the usage of the CAN controller and the interaction of two or more
193-
controllers. Although the CAN controllers would typically belong to different participants and reside in different
194-
processes, their interaction is shown sequentially to demonstrate cause and effect.
199+
This section contains complete examples that demonstrate the use of the CAN controller and the interaction between
200+
two or more controllers.
201+
202+
Although the CAN controllers would typically belong to different participants and reside in different
203+
processes, their interaction is shown sequentially here to demonstrate cause and effect.
195204

196205
Assumptions:
197206

docs/overview/overview.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ It provides:
2626

2727
* Implemented in C++ w/o platform dependencies
2828

29-
* Interoperability between Windows, Linux, and other UNIX derivates
29+
* Interoperability between Windows, Linux, and other UNIX derivatives
3030

3131
* Stable API and ABI as well as long-term network layer compatibility
3232

@@ -50,14 +50,20 @@ Vehicle Networks
5050
The |ProductName| provides means to simulate |CANBuses|, Ethernet, FlexRay, and LIN networks.
5151
All networks except for FlexRay can be simulated with two different levels of detail: a simple, functional simulation or a detailed simulation.
5252
The simple simulation assumes no delay and unlimited bandwidth.
53+
5354
The detailed simulation is enabled by using an additional |ProductName| |NetSim|, which considers these aspects as well.
5455
The |NetSim| is not part of |ProductName| itself.
5556
Because of its sensitivity regarding time, FlexRay is only supported in a detailed simulation.
5657

5758
Vehicle networks are accessed through their corresponding services (e.g., a CAN controller).
5859
The service interfaces are the same for simple and detailed simulation.
5960
As a result, an application that works in the simple use case also works when switching to a detailed simulation using the |NetSim|.
60-
The section :ref:`sec:api-services` describes how to configure and use vehicle network services in detail.
61+
62+
In general, |ProductName| deliberately avoids imposing restrictions on bus protocols.
63+
This enables user applications to freely determine the desired level of detail for vehicle network simulations.
64+
For example, a test participant can inject faulty frames without being blocked by |ProductName|.
65+
66+
The section :ref:`sec:api-services` describes how to configure and use the vehicle network services in detail.
6167

6268
Simulation Basics
6369
-----------------
@@ -78,8 +84,8 @@ Furthermore, |ProductName| participants can use a virtual simulation time that i
7884
While participants are first configured in the |ProductName| API by the developer, they can be reconfigured by the user by providing a YAML-based participant configuration file when starting the participant.
7985
A similar configuration file is available for the |ProductName| Registry as well.
8086

81-
* For getting started operating/orchestrating a |ProductName| simulation, see the :doc:`User Guide <../for-users/users>`.
82-
* For getting started developing with the |ProductName|, see the :doc:`Developer Guide <../for-developers/developers>`.
87+
* To get started operating/orchestrating a |ProductName| simulation, see the :doc:`User Guide <../for-users/users>`.
88+
* To get started developing with the |ProductName|, see the :doc:`Developer Guide <../for-developers/developers>`.
8389

8490
.. _sec:overview-ecosystem:
8591

@@ -104,10 +110,10 @@ The |ProductName| ecosystem comprises the following turn-key solutions:
104110
can be used to attach a virtual CAN (Controller Area Network) interface (SocketCAN) to a Vector SIL Kit CAN bus.
105111

106112
* The `SIL Kit Adapter for Generic Linux IO <https://github.com/vectorgrp/sil-kit-adapters-generic-linux-io>`_
107-
allows to attach SIL Kit to a generic Linux IO device, such as character devices or GPIOs.
113+
allows attaching SIL Kit to a generic Linux IO device, such as character devices or GPIOs.
108114

109115
* The `SIL Kit FMU Importer <https://github.com/vectorgrp/sil-kit-fmu-importer>`_
110-
allows to import Functional Mockup Units (FMUs) as SIL Kit participants.
116+
can import Functional Mockup Units (FMUs) as SIL Kit participants.
111117

112118
Related Applications
113119
~~~~~~~~~~~~~~~~~~~~
@@ -127,12 +133,12 @@ Guiding Principles
127133

128134
* **Local view:** Participants do not require knowledge about the overall system setup or other participants.
129135
Communication between participants is made possible by using a common bus network or topic name.
130-
* **Distributed simulation:** Communication between participants is based on a peer-to-peer connections.
136+
* **Distributed simulation:** Communication between participants is based on peer-to-peer connections.
131137
There is no central simulation participant that handles the distribution of messages or controls the virtual time.
132138
* **Stability:** |ProductName| has a stable network layer and provides API and ABI guarantees.
133139
This means that participants of different versions can partake in the same simulation.
134140
Further, the |ProductName| library can be updated to newer versions without having to adapt or recompile already existing |ProductName| applications.
135-
* **Reconfigurability:** Users should be able to provide a configuration file to the SIL Kit application to change the its behavior (e.g., configure logging or change the network a bus controller connects to).
141+
* **Reconfigurability:** Users should be able to provide a configuration file to the SIL Kit application to change its behavior (e.g., configure logging or change the network a bus controller connects to).
136142

137143
.. _sec:overview-terminology:
138144

@@ -149,7 +155,7 @@ Terminology
149155
- A participant is a communication node in the distributed simulation that provides access to the |ProductName| services.
150156
* - :ref:`Services<sec:api-services>`
151157
- Participants interact with each other through the means of services.
152-
These can be communication services, e.g., a :doc:`CAN Controller</api/services/can>` and orchestration services, such as the the Lifecycle Service, Time Synchronization Service, and the Logging Service.
158+
These can be communication services, e.g., a :doc:`CAN Controller</api/services/can>` and orchestration services, such as the Lifecycle Service, Time Synchronization Service, and the Logging Service.
153159
* - :doc:`Configuration<../configuration/configuration>`
154160
- The optional participant configuration file allows easy configuration of a participant and its interconnection within the simulation.
155161
It can be used to change a participant's behavior without recompiling its sources.
@@ -183,7 +189,7 @@ Terminology
183189
Further Reading
184190
---------------
185191

186-
More real-world examples involving time synchronization and simulated automotive networks, can be found in the :doc:`API sections<../api/api>`.
192+
More real-world examples involving time synchronization and simulated automotive networks can be found in the :doc:`API sections<../api/api>`.
187193
Also, studying the source code of the bundled :doc:`demo applications<../demos/demos>` is a good start.
188194
The simulation lifecycle and supported simulation time synchronization are discussed in :doc:`../simulation/simulation`.
189195
Additionally, :doc:`../configuration/configuration` describes how the participant configuration file can be used to change the behavior of participants.

0 commit comments

Comments
 (0)