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:
- Launch a supported version of Visual Studio.
- 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.
- Filter all available project templates by C++ Language and wRTOS Platform.
- Select the wRTOS Application template.
- Specify the Name and Location for the new project, then click Create. In this example, we will use the name
wRTOSApp1and the location ofC:\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.
- View the current project settings.
- Ensure that the Provide an RTSS application framework option is selected.
- Select a provided framework.
- Click Finish.
Notes
Upon completion of the wRTOS Application template there are a few things worth noticing:
- Your project will have these configurations:
x64
- RTSSDebug – Real-time application that has debug flags enabled
- RTSSRelease – Real-time application without additional debug information
- Debug – Windows 64-bit application linked to wRTOS that has debug flags enabled
- Release – Windows 64-bit application linked to wRTOS
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.
- In the generated Header file, you will see wRTOS-specific header files:
- RTAPI.h – this header file is needed by both Windows applications linked to wRTOS and RTSS application
- RTSSAPI.h – this header file is only needed by RTSS applications
- In the project's C/C++ settings you will see the addition of wRTOS-specific paths:
- %wRTOSSDKDir<MAJORVERSION>%\include
For example, for wRTOS 1.0.1 - version 1.0 of the wRTOS product - the path is %wRTOSSDKDir1%\include
- In the project's linker settings, you will see the addition of wRTOS-specific paths, preprocessor definitions, and libraries:
- wRTOSPlatform macro is defined to point to the correct libraries based on the platform selected, 32-bit or 64-bit.
- UNDER_RTSS preprocessor definition for defining wRTOS-specific functionality
- VERSION_AS_STR definition in wRTOSVersion.h that can be used to check the product version
- Windows configurations:
%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
- RTSS Configurations:
%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
- 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.
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.
- Open the new program shell by selecting it from the list of Source Files.
- For the first modification, increase the timer period from 500 microseconds to 1 second.
// 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;
- Next, set the test duration to 5 seconds and then display a completion message.
//
// TO DO: Your program code here
//
Sleep(5000); // test duration = 5 seconds
RtWprintf(L"*** test finished\n");
- Open the wRTOSApp1RtTimerThread.cpp file for the wRTOS application and add a line to display status when the
TimerHandleris called.
{
// TO DO: Your timer handler code here
RtWprintf(L"Timer proc...\n");
}
Build and run a wRTOS executable:
- Set the Solution Configuration so that the program will be built as an RTSSDebug executable.
- Select Build Solution from the Build pull-down menu.
-
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:
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: