Creating a wRTOS Application in Visual Studio

In this section, we show you how to create a new project in Visual Studio using the wRTOS Application Template and modify the basic project framework.

Create a new Visual Studio project:

  1. Launch a supported version of Visual Studio.
  2. Create a new project: click Create a new project from the Visual Studio Start Page.

Select the Application Template:

In the Create a new project dialog, you can select the wRTOS application templates for creating a wRTOS application, network driver, and device driver.

  1. Filter all available project templates by C++ Language and wRTOS Platform.
  2. Select the wRTOS Application template.
  3. Specify the Name and Location for the new project, then click Create. In this example, we will use the name wRTOSApp1 and the location of C:\Samples\wRTOS.

Configure the wRTOS Application Template

The wRTOS Application template provides basic project settings and compiler and linker options. For more information, see Compiler and Linker Options.

  1. View the current project settings.
  2. Ensure that the Provide an RTSS application framework option is selected.
  3. Select a provided framework.
  1. Click Finish.

Notes

Upon completion of the wRTOS Application template there are a few things worth noticing:

  1. Your project will have these configurations:

x64

Note: You can also build 32-bit configurations. For more information on how to build 32-bit configurations, see Building a 32-bit User Space Application.

  1. In the generated Header file, you will see wRTOS-specific header files:
  1. In the project's C/C++ settings you will see the addition of wRTOS-specific paths:

For example, for wRTOS 1.0.1 - version 1.0 of the wRTOS product - the path is %wRTOSSDKDir1%\include

  1. In the project's linker settings, you will see the addition of wRTOS-specific paths, preprocessor definitions, and libraries:

%wRTOSSDKDir<MAJORVERSION>%\lib\$(wRTOSPlatform) - additional path for the wRTOS libraries

For example, for wRTOS 1.0.1 - version 1.0 of the wRTOS product - the path is %wRTOSSDKDir1%\lib\$(wRTOSPlatform)

rtapi.lib – library that provides Windows application with the ability to interact with RTSS processes

%wRTOSSDKDir<MAJORVERSION>%\lib\$(wRTOSPlatform) – additional path for the wRTOS libraries

Startup.lib or StartupCRT.lib – libraries used of wRTOS startup functionality

Rtx_rtss.lib – library that provides wRTOS support and functionality

  1. In the project's Build events and Post-build events you will see an event for StampTool. This step licenses all created binaries to run on a target system with a valid RTSS Subsystem.

Note: Only RTSS and RTDLL applications need to be stamped by StampTool.

Modify the program

The new project contains a basic program framework consisting of source and header files, as well as additional elements for the framework that was chosen. Once the project has been created, you can modify the program source code.

  1. Open the new program shell by selecting it from the list of Source Files.
  2. For the first modification, increase the timer period from 500 microseconds to 1 second.
Copy
//    TO DO:    Set default timer period.
//              The period must be an even multiple of the HAL
//              timer period value in wRTOS Settings.
//              This example uses a timer period of 500 microseconds.

liPeriod.QuadPort = 10000000;
  1. Next, set the test duration to 5 seconds and then display a completion message.
Copy
//
//    TO DO:    Your program code here
//              

Sleep(5000); // test duration = 5 seconds
RtWprintf(L"*** test finished\n");
  1. Open the wRTOSApp1RtTimerThread.cpp file for the wRTOS application and add a line to display status when the TimerHandler is called.
Copy
{
    //    TO DO:    Your timer handler code here
    RtWprintf(L"Timer proc...\n");
}

Build and run a wRTOS executable:

  1. Set the Solution Configuration so that the program will be built as an RTSSDebug executable.
  2. Select Build Solution from the Build pull-down menu.
  3. If your development system also contains wRTOS Runtime, you can run the .rtss executable either by double-clicking on the file name in Explorer or by typing it into a command prompt:

  4. rtssrun C:\Samples\wRTOS\x64\RTSSDebug\wRTOSApp1.rtss

    If your Runtime is located on a different system, you will need to copy the binary to that system first.

related TOPICS: