Overview of Lesson 3

What you will learn

In this lesson you will learn how to transfer data between the simulation platform and the host PC:

  • You will learn how to implement event handling.

  • You will learn how to print messages to the dSPACE Log.

  • You will learn how to implement exception handling to transfer data.

  • You will learn how to use dynamic variables to make data available on the simulation platform and on the host PC.

  • You will learn how to use host calls to exchange data between the simulation platform and the host PC.


Steps


Brief comparison of methods to transfer data

There are different possibilities to transfer data from the simulation platform to the host PC. The methods used in this lesson are briefly compared in the following table:

Note

None of these methods is suitable to implement a kind of capture.

Methods

Advantages

Disadvantages

Typical Use Case

print statements

  • Easy to implement.

  • Time consuming

  • Print output can be lost (4 kB output buffer).

  • No data exchange possible. A string can be sent from the simulation platform to the standard output of the host PC via event handling.

Mainly used for debugging.

Writing to dSPACE Log

  • Messages can be viewed, for example, in ControlDesk.

  • Messages can be written to the dSPACE Log with different severity levels.

  • Time consuming

  • The maximum length of a message is 4088 characters.

  • No data exchange possible.

Mainly used for logging.

Exceptions

  • Data loss can be excluded.

  • No data exchange possible. Data is sent from the simulation platform to the host PC.

  • Only strings can be sent with an exception.

  • If an exception is thrown, the RTT sequence is stopped (error state).

Used only to implement exception handling.

Dynamic variables

  • Easy to implement.

  • Directly accessible on the simulation platform and on the host PC.

  • Can be used as user interface between the host PC and the RTT sequences.

  • Persist as long as the simulation application is loaded on the simulation platform.

  • Extended functionality with the DynamicValue attribute, which supports several data types (Boolean, integer, float, string, tuple).

  • Dictionaries and Python objects are not supported by the DynamicValue attribute.

  • Data loss cannot be excluded with certainty. Data can get lost, for example, if the dynamic variable is changed faster within an RTT sequence than the host PC can read the data.

  • Dynamic variables are persistent and can be removed only by reloading the simulation application.

Mainly used as user interface.

Host calls

  • Complex tasks can be sent to the host PC to avoid task overruns on the simulation platform.

  • Data can be exchanged between the simulation platform and the host PC and vice versa.

  • Python objects can be exchanged with host calls.

  • The RTT sequence is paused until the host PC has answered the host call.

  • A relatively long period of time is required for a host call.

  • The maximum size of the sent data is limited to 10 kbit.

Mainly used for processing complex tasks.


Result and further information

To check the learning results of the steps you executed and for further information, refer to Result of Lesson 3.


Duration

Working through this lesson will take you about 60 minutes.


Redaction