WindowswRTOSUsingSTL Sample
This sample demonstrates data exchange between a real-time process and a Windows user-space process using C++ STL classes to manage the data that is exchanged via a shared memory region.
Source Files
There are three folders in this sample:
- The Common folder contains common code referenced by the projects in the other two folders.
- The RtConsumer folder contains a project and source code to build a real-time process that consumes data produced by a Windows user-space application, modifies it, and sends it back to the Windows application.
- The WinProducer folder contains a project and source code to build a Windows user-space application that produces data to be consumed by a real-time application. This application also displays the data after it has been modified by the real-time application.
Common
| File | Description |
|---|---|
| common.h | Header file |
| DataOwner.cpp | Implementation of class DataOwner, which manages a shared memory region used to transfer data between the real-time process and the Windows process. |
| DataOwner.h | Header file for class DataOwner |
RtConsumer
| File | Description |
|---|---|
RealTimeConsumer.h
|
Header file for class RealTimeConsumer. |
RealTimeConsumer.cpp
|
Implementation of class RealtimeConsumer, which waits on an event and when that event is signaled by the WinProducer application, consumes the data. |
RtConsumer.h
|
Header file. |
RtConsumer.cpp
|
A real-time application that instantiates class RealtimeConsumer and operates that instance. |
RtConsumer_VS<Visual Studio Version>.vcxproj
|
Project file for supported versions of Visual Studio. |
RtConsumer_VS<Visual Studio Version>.vcxproj.filters
|
Project filters file for supported versions of Visual Studio. |
RtConsumer_VS<Visual Studio Version>.sln
|
Solution file for supported versions of Visual Studio. |
WinProducer
| File | Description |
|---|---|
| WinProducer.h | Header file. |
| WinProducer.cpp | A windows application that sends data and commands to the real-time consumer application using shared memory and an event. |
| WinProducer_VS<Visual Studio Version>.vcxproj | Project file for supported versions of Visual Studio. |
| WinProducer_VS<Visual Studio Version>.vcxproj.filters | Project filters file for supported versions of Visual Studio. |
| WinProducer_VS<Visual Studio Version>.sln | Solution file for supported versions of Visual Studio. |
Building the Sample
Build both RtConsumer (RTSSDebug or RTSSRelease configurations) and WinProducer (Debug or Release configurations).
Running the Sample
Start the RtConsumer real-time application first, then start the WinProducer application.
Expected Results
- RtConsumer enters a command processing loop waiting for commands from WinProducer.
- WinProducer sends commands to create and start the real-time consumer, adds data owners, and updates shared data periodically.
- Output on the WinProducer console shows input and modified output values from the real-time process.
- Upon completion, WinProducer sends a stop command and both processes exit.
Unexpected Results
- WinProducer starts before RtConsumer, causing it to fail when opening shared memory.
Remarks
- Shared memory is created and opened by RtConsumer and accessed by WinProducer.
- Communication relies on polling a shared flag (commandIsReady) and commands sent via shared memory.
- Synchronization uses wRTOS events internally (not shown explicitly).
- Real-time thread priorities and timing are handled inside RtConsumer.
- The sample requires wRTOS subsystem to be running and both projects to be configured appropriately.
APIs Referenced
|
RTAPI |
|---|