uart example

This example demonstrates use of the Universal Asynchronous Receiver-Transmitter (UART) driver in KasperskyOS.

Example directory in the SDK

The code of the example and build scripts are available at the following path:

/opt/KasperskyOS-Community-Edition-<platform>-<version>/examples/uart

List of programs

When you build an example for the target hardware platform, platform-specific drivers are automatically included in the solution:

Initialization description

The solution initialization description file named init.yaml is generated during the solution build process based on the ./einit/src/init.yaml.in and ./einit/init_qemu.yaml.in templates. Macros in @INIT_*@‌ ‌format contained in the template are automatically expanded in the resulting init.yaml file. For more details, refer to init.yaml.in template.

Security policy description

The security.psl file contains the solution security policy description and is generated based on the ./einit/src/security.psl.in template during the solution build process. For more details, refer to "security.psl.in template".

The solution security policy description in this example allows any interaction between different processes and between processes and the kernel. This policy can be used only as a stub during the early stages of a solution development so that the security module does not interfere with interactions. It would be unacceptable to apply such a policy in a real-world KasperskyOS-based solution.

Resources

The directory ./resources/xdl/uart contains the EDL description for the Client program.

Operating scenario

The Client program performs the following actions:

  1. Moves logging to the user space to gain exclusive access to the UART port.
  2. Initializes the UART driver.
  3. Opens the port with the number specified by the PORT_NAME macro and configures it with the defined parameters.
  4. Sends the string Hello world with UART! to the open port.
  5. Closes the port, deinitializes the driver, and terminates the program with the EXIT_SUCCESS code if there are no errors. Otherwise it shows the EXIT_FAILURE code.

Building and running the example

The CMake system, which is included with KasperskyOS Community Edition, is used to build and run the example.

For the example to work correctly on the Radxa ROCK 3A, do the following:

See Building and running examples section.

Page top