Studio:SCL Samples

From STRIDE Wiki
Jump to navigation Jump to search

Note: for content related to versions of STRIDE 3.0.0101a and earlier, please refer to SCL Samples v3.0.0101a

Introduction

The following content relates to the sample files and workspace installed in %STRIDE_DIR%\Samples\SCL. This sample consists of several header files containing examples of STRIDE Communication Language (SCL) source code, and a STRIDE workspace that includes these source files for compilation.

Prerequisites

Before starting, some prerequisites must be satisfied. For details and instructions, see Host Installation.

Specifically:

  • STRIDE must be installed on the Windows PC to be used in the training, and any required licenses must be present.

Sample Files

Begin by opening the SCL.ssw sample workspace and compiling the SCL sample code it contains. Next, examine the Source Files workspace folder (in the Files tab). It contains the sub-folders and header files that provide examples of SCL usage. Some of these files have sections that provide source code that can be used with the SCL Wizard. Refer to the #SCL Wizard Examples section below for details.

This section provides a brief description for each of the sample categories.

Capture

This folder contains the following header files that demonstrate how to use SCL to identify and define interfaces on the target.

Functions.h

This header file demonstrates the usage of the scl_func and scl_function SCL pragmas.

Messages.h

This header file demonstrates the usage of the scl_msg SCL pragma to define several different types of interfaces: one way command, one way response, two way, and broadcast messages.

TestUnits.h

This header file demonstrates the usage of the scl_test_class, scl_test_cclass, scl_test_flist, scl_test_setup, and scl_test_teardown SCL pragmas to define test unit interfaces.

Qualification

This folder contains the following header files that demonstrate how to use SCL to annotate or markup interface payloads for communication with the target.

Casting.h

This header file demonstrates the usage of the scl_cast pragma. One example shows how to use SCL to cast an integer field to an enumerated type, effectively constraining the values that may be allowed for that field. Another example shows how to use the scl_cast pragma to cast an integer pointer to a pointer to enumerated type, constraining the values that that field may point to.

FunctionCallbacks.h

This header file demonstrates how to use the scl_ptr_flist pragma to identify functions that may be associated with a function pointer field in a payload. This illustrates a concept where callback functions may be communicated between user and owner. Examples include using a form of the pragma to declare an anonymous function interface (the "default function"), and using the pragma to associate previously captured functions with the function pointer field.

Pointers.h

This header file demonstrates the use of the scl_ptr, scl_ptr_opaque, and scl_ptr_sized pragmas.
In the scl_ptr examples, it is shown how to apply the pragma to pointer fields within structure types. The effect is that these pragmas are implicitly applied to the interface payloads that use these structure types. Then it is shown how to override the pragma settings by explicitly setting pointer attributes to individual interface payload fields. The sample code shows how to apply the "OUT" and "INOUT" directional attributes to payload fields, in order for the user to receive data back from the owner when the interface call is made.
The scl_ptr_opaque example shows how to apply the pragma to a pointer type field, as well as an individual payload field.
The scl_ptr_sized examples show how to use the pragma to associate a size field with a pointer field to indicate the number of elements allocated to the pointer. The first pragma sample shows a pointer in the command payload qualified as a sized pointer, and the second sample shows the function return value qualified as a sized pointer.

Strings.h

This header file demonstrates the use of the scl_string pragma. The sample shows how to specify a pointer to short (Unicode) as a string, and an array of char as a string.

Unions.h

This header file demonstrates the use of the scl_union, and scl_union_activate pragmas. The sample shows a form of the pragma that designates a fixed active member, one that designates a discriminant with default mapping, and one that designates a discriminant with explicit mapping, using the scl_union_activate pragmas as additive specifications to the union.

Values.h

This header file demonstrates the use of the scl_values pragma to constrain the allowable values for a payload field. The sample shows a form of the pragma that specifies a list of values, and a form that specifies an enumerated type.

Advanced

This folder contains the following header files that demonstrate advanced techniques where SCL is used in a way that solves difficult customer issues.

Ioctl.h

VariantMessage.h

SCL Wizard Examples

Functions.h

Casting.h

FunctionCallbacks.h

Pointers.h

Strings.h

Unions.h

Values.h