<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://www.sinelabore.com/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>SinelaboreRT - wiki:howto</title>
        <description>Productivity for embedded software development</description>
        <link>https://www.sinelabore.com/</link>
        <lastBuildDate>Wed, 08 Apr 2026 12:27:14 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://www.sinelabore.com/lib/exe/fetch.php/favicon.ico</url>
            <title>SinelaboreRT</title>
            <link>https://www.sinelabore.com/</link>
        </image>
        <item>
            <title>Astah* Howto</title>
            <link>https://www.sinelabore.com/doku.php/wiki/howto/astah</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;astah_howto&quot;&gt;Astah* Howto&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
See “The code generator has problems to find Astah models” in the &lt;a href=&quot;https://www.sinelabore.com/doku.php/wiki/howto/javaproblems&quot; class=&quot;wikilink1&quot; title=&quot;wiki:howto:javaproblems&quot; data-wiki-id=&quot;wiki:howto:javaproblems&quot;&gt;Java FAQ&lt;/a&gt;
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Thu, 21 May 2020 15:22:28 +0000</pubDate>
        </item>
        <item>
            <title>How to use state machines generated by Sinelabore with the CubeMX tool from STM</title>
            <link>https://www.sinelabore.com/doku.php/wiki/howto/cubemx</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;how_to_use_state_machines_generated_by_sinelabore_with_the_cubemx_tool_from_stm&quot;&gt;How to use state machines generated by Sinelabore with the CubeMX tool from STM&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
This example shows how easy it is to add statemachines to STM32 CubeMX projects.
&lt;/p&gt;

&lt;p&gt;
The example was created for the STM32F103C8T, for which very cheap eval boards are available. 
&lt;/p&gt;

&lt;p&gt;
The graphic shows the typical development flow for a CubeMX project and where the Sinelabore State Machine Generator comes into play.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://www.sinelabore.com/lib/exe/detail.php/wiki/howto/stm32_demo.svg?id=wiki%3Ahowto%3Acubemx&quot; class=&quot;media&quot; title=&quot;wiki:howto:stm32_demo.svg&quot;&gt;&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/stm32_demo.svg?w=600&amp;amp;tok=203b36&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Example project generated with the CubeMX and Sinelabore&quot; alt=&quot; Example project generated with the CubeMX and Sinelabore&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
In the example, CMSIS &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; is used with 2 tasks, a message queue  and a timer. The state machine runs in &lt;code&gt;Task02&lt;/code&gt; and receives its events from the timer callback function &lt;code&gt;cyclicTimer0Callback&lt;/code&gt;. And also from the default task. The state machine is kept simple and generates a blinking pattern that is terminated after some time by a FailSafe event.
&lt;/p&gt;

&lt;p&gt;
The Statemachine was created with the integrated &lt;a href=&quot;https://www.sinelabore.com/doku.php/wiki/manual/editor&quot; class=&quot;wikilink1&quot; title=&quot;wiki:manual:editor&quot; data-wiki-id=&quot;wiki:manual:editor&quot;&gt;Statediagram Editor&lt;/a&gt;. To modify the machine, start the editor, load the model and regenerate the code after your changes.
&lt;/p&gt;

&lt;p&gt;
Follow the steps below to create the example itself. It is assumed that you have installed the GNU Arm compiler tools and a debug interface. Links to the tools you need can be found below.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Download the demo project zip and unzip it&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Create a project folder &lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Copy the project file to your project folder and load the project with the CubeMX programme.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Generate the complete project code from it into the project folder.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Replace the generated Makefile with the modified Makefile provided in the demo project folder. The modified Makefile contains the state machine C/H path.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Finally replace &lt;code&gt;main.c&lt;/code&gt; in the Core/Src folder with the demo version. It contains the application from two tasks.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Now you can call make and flash the created elf file into the board with the debugger. 
&lt;/p&gt;

&lt;p&gt;
In one console run the debug stub;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; /opt/homebrew/bin/st-util&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
In another console run the debugger:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;/Applications/ARM/bin/arm-none-eabi-gdb&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;target remote 192.168.6.191:4242&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;load build/example.elf&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;file build/example.elf&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;c&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The ARM Tools and CubeMX make it super easy to get started with the STM uC family and the Sinelabore Statemachine Generator completes the toolschain perfectly.
&lt;/p&gt;
&lt;hr /&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;How to use state machines generated by Sinelabore with the CubeMX tool from STM&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;how_to_use_state_machines_generated_by_sinelabore_with_the_cubemx_tool_from_stm&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;1-2298&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit2&quot; id=&quot;links&quot;&gt;Links&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Required project files: &lt;a href=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/stm_tutorial.zip&quot; class=&quot;media mediafile mf_zip&quot; title=&quot;wiki:howto:stm_tutorial.zip (59.1 KB)&quot;&gt;stm_tutorial.zip&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Blue Pill Development Board: &lt;a href=&quot;https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill.html&quot; class=&quot;urlextern&quot; title=&quot;https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill.html&quot; rel=&quot;ugc nofollow&quot;&gt;https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill.html&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Docu of the STM32CubeIDE ST-LINK GDB server: &lt;a href=&quot;https://www.st.com/resource/en/user_manual/um2576-stm32cubeide-stlink-gdb-server-stmicroelectronics.pdf&quot; class=&quot;urlextern&quot; title=&quot;https://www.st.com/resource/en/user_manual/um2576-stm32cubeide-stlink-gdb-server-stmicroelectronics.pdf&quot; rel=&quot;ugc nofollow&quot;&gt;https://www.st.com/resource/en/user_manual/um2576-stm32cubeide-stlink-gdb-server-stmicroelectronics.pdf&lt;/a&gt; &lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; CMSIS-RTOS2 Docu: &lt;a href=&quot;https://www.keil.com/pack/doc/CMSIS/RTOS2/html/genRTOS2IF.html&quot; class=&quot;urlextern&quot; title=&quot;https://www.keil.com/pack/doc/CMSIS/RTOS2/html/genRTOS2IF.html&quot; rel=&quot;ugc nofollow&quot;&gt;https://www.keil.com/pack/doc/CMSIS/RTOS2/html/genRTOS2IF.html&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Arm GNU Toolchain Downloads: &lt;a href=&quot;https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads&quot; class=&quot;urlextern&quot; title=&quot;https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads&quot; rel=&quot;ugc nofollow&quot;&gt;https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Open source version of the STMicroelectronics STLINK Tools: &lt;a href=&quot;https://github.com/stlink-org/stlink&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/stlink-org/stlink&quot; rel=&quot;ugc nofollow&quot;&gt;https://github.com/stlink-org/stlink&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Links&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;links&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;2299-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Wed, 11 Oct 2023 19:11:58 +0000</pubDate>
        </item>
        <item>
            <title>Enterprise Architect HowTo</title>
            <link>https://www.sinelabore.com/doku.php/wiki/howto/enterprise_architect_how-to</link>
            <description>
&lt;p&gt;
Enterprise Architect HowTo
&lt;/p&gt;

&lt;h1 class=&quot;sectionedit1&quot; id=&quot;enterprise_architect_howto&quot;&gt;Enterprise Architect HowTo&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
Below some tips and tricks are listed that simplify the state-chart creation using Enterprise Architect. If you have further hints let us know and we add them here. For a short intro on on how to use EA with the codegen go on reading &lt;a href=&quot;https://www.sinelabore.com/doku.php/wiki/landing_pages/ea&quot; class=&quot;wikilink1&quot; title=&quot;wiki:landing_pages:ea&quot; data-wiki-id=&quot;wiki:landing_pages:ea&quot;&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt; &lt;strong&gt; Where to put the events to:&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; States should be put “below” the class containing the state diagram. See next figure.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/ea_howto_model_browser_ea9.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;
&lt;hr /&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt; &lt;strong&gt; How to define the path to the state machine:&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; Since version 9.0 of Enterprise architect it looks like that always a view package is required. This package must appear in the path you specify on the codegen command line. In the figure above the path to the state machine is -t “Model:test:testclass”
&lt;/p&gt;
&lt;hr /&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt; &lt;strong&gt; I always get the error message ‘Can&amp;#039;t find path element ….’. But I’m sure the path is correct:&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; Most probably you have not selected to root element (e.g. Model in the figure above) before exporting the XMI file. Select the root model element and then export to XMI.
&lt;/p&gt;
&lt;hr /&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt; &lt;strong&gt; How to specify multiple lines entry/exit/do action code:&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; So far there were two ways. The codegen took the name of the action as code. To specify multiple lines it was necessary to specify several actions. The other option was to attach a comment to a state and define the code there. 
&lt;/p&gt;

&lt;p&gt;
Now with EA 9.2 it is possible to specify multiple lines of action code in the behavior field. The name of the action is not used anymore as code line if code is found in the behavior field. The strange thing is that EA allows to define initial code which is unfortunately not exported in the normal XMI state tree. So it can&amp;#039;t be used right now. In the example below two lines of entry code were added to S1.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/ea_howto_state_action_code.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt; &lt;strong&gt; Where do I find the “export to XMI” dialog? &lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; In recent versions of EA the export to XMI is available under &lt;code&gt;Publish → Export XMI&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt; &lt;strong&gt; EA updates the model file when loading with the new EA17Beta. Notes that were previously linked to the class are incorrectly linked to the state diagram. &lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; Link the Notes again with the class in which the state diagram is contained.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://www.sinelabore.com/lib/exe/detail.php/wiki/howto/ea17beta_sm.png?id=wiki%3Ahowto%3Aenterprise_architect_how-to&quot; class=&quot;media&quot; title=&quot;wiki:howto:ea17beta_sm.png&quot;&gt;&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/ea17beta_sm.png?w=600&amp;amp;tok=d74cb7&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
&lt;a href=&quot;https://www.sinelabore.com/lib/exe/detail.php/wiki/howto/ea17beta_class.png?id=wiki%3Ahowto%3Aenterprise_architect_how-to&quot; class=&quot;media&quot; title=&quot;wiki:howto:ea17beta_class.png&quot;&gt;&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/ea17beta_class.png?w=600&amp;amp;tok=fd2fb6&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Enterprise Architect HowTo&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;enterprise_architect_howto&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;46-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Sun, 04 Aug 2024 12:12:51 +0000</pubDate>
        </item>
        <item>
            <title>Java problems</title>
            <link>https://www.sinelabore.com/doku.php/wiki/howto/javaproblems</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;java_problems&quot;&gt;Java problems&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt;&lt;strong&gt;Java does not find the codegen or other jar files:&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; Newer Java version only accept the class path syntax. This means you have to update your Makefile or built scrips. The class path must be adjusted according your installation of course.
&lt;/p&gt;

&lt;p&gt;
On Linux/Unix/Mac use the following format:&lt;br/&gt;

&lt;code&gt;-cp ../../bin/*:../* codegen.Main&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
On Windows use this format (even displayed differently here use normal quotation marks):&lt;br/&gt;

&lt;code&gt;-cp “..\..\bin\*;..\*” codegen.Main&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt;&lt;strong&gt;The code generator has problems to find Astah models&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; The code generator uses the public &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; to access the Astah models. Therefore the Java class path must contain the path to the Astah Java &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;. The following class path shows how to do this. Take care to consider class path differences under Windows and Unix like systems.
&lt;/p&gt;

&lt;p&gt;
&lt;code&gt;-cp “..\..\bin\*;..\*;C:\Program Files\astah-professional\*” codegen.Main&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; Also make sure the file extension is according to the Astah rules. Otherwise Astah does not accept the files as input model:&lt;br/&gt;

For Astah Professional: &lt;code&gt;.asta&lt;/code&gt;&lt;br/&gt;

For Astah SysML: &lt;code&gt;.asml&lt;/code&gt;&lt;br/&gt;

&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Sat, 05 Dec 2020 16:11:22 +0000</pubDate>
        </item>
        <item>
            <title>Magic Draw</title>
            <link>https://www.sinelabore.com/doku.php/wiki/howto/magic_draw</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;magic_draw&quot;&gt;Magic Draw&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt;&lt;strong&gt;I don&amp;#039;t see the on-entry/on-exit/do code in my state diagram &lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; Since MD version 19 (at least recognised it there) it is necessary to copy your code to the body text. See example below:
&lt;a href=&quot;https://www.sinelabore.com/lib/exe/detail.php/wiki/howto/md_19_hint1.png?id=wiki%3Ahowto%3Amagic_draw&quot; class=&quot;media&quot; title=&quot;wiki:howto:md_19_hint1.png&quot;&gt;&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/md_19_hint1.png&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;Specification of action code for a state&quot; alt=&quot;Specification of action code for a state&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt;&lt;strong&gt;Is it necessary to specify an action name for on-entry/on-exit/do code?&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; If there is text in the name fieled (as shown above) it will be considered for code generation. If the name field is left empty the body part is used for code generation. The body text can be longer than one line. An example is shown below.
&lt;a href=&quot;https://www.sinelabore.com/lib/exe/detail.php/wiki/howto/md_long_actions.png?id=wiki%3Ahowto%3Amagic_draw&quot; class=&quot;media&quot; title=&quot;wiki:howto:md_long_actions.png&quot;&gt;&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/md_long_actions.png?w=300&amp;amp;tok=b77dab&quot; class=&quot;medialeft&quot; align=&quot;left&quot; loading=&quot;lazy&quot; title=&quot;Either specify code in the name filed or the body field.&quot; alt=&quot;Either specify code in the name filed or the body field.&quot; width=&quot;300&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Mon, 24 Jan 2022 18:36:45 +0000</pubDate>
        </item>
        <item>
            <title>Modelio</title>
            <link>https://www.sinelabore.com/doku.php/wiki/howto/modelio</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;modelio&quot;&gt;Modelio&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/question.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:?:&quot; /&gt;&lt;strong&gt;What options should I use for exporting a XMI file in Modelio 3&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://www.sinelabore.com/lib/images/smileys/exclaim.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:!:&quot; /&gt; Select the following options:
&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/modelio_xmi_export_2.png&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Mon, 30 Sep 2013 18:11:31 +0000</pubDate>
        </item>
        <item>
            <title>How to use state machines with a real-time operating system</title>
            <link>https://www.sinelabore.com/doku.php/wiki/howto/rtos</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;how_to_use_state_machines_with_a_real-time_operating_system&quot;&gt;How to use state machines with a real-time operating system&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
State machines can be used in various places of your system. In this example you will learn how to use a state machine in the context of a &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; (real-time operating system). For this exercise it does not really matter which &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; you have in place. Because the general approach is always the same. Let&amp;#039;s use &lt;a href=&quot;https://freertos.org&quot; class=&quot;urlextern&quot; title=&quot;https://freertos.org&quot; rel=&quot;ugc nofollow&quot;&gt;FreeRTOS&lt;/a&gt; here.
&lt;/p&gt;

&lt;p&gt;
FreeRTOS is a market-leading real-time operating system (&lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt;) for microcontrollers and small microprocessors. 
&lt;/p&gt;

&lt;p&gt;
There is a Windows port layer which allows to quickly test how to use the state machine code generated by the SinelaboreRT code generator on your computer.
&lt;/p&gt;

&lt;p&gt;
In this design pattern state machines run in the context of an own task. The principle design is shown in the following figure.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://www.sinelabore.com/lib/exe/detail.php/mainloop_ext.svg?id=wiki%3Ahowto%3Artos&quot; class=&quot;media&quot; title=&quot;mainloop_ext.svg&quot;&gt;&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/mainloop_ext.svg?w=400&amp;amp;tok=6ebb68&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;Using state machines in a main loop with event queue&quot; alt=&quot;Using state machines in a main loop with event queue&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Each task executes a state machine (often called active object) in an endless while loop. The tasks wait for new events to be processed from the state machine. In case no event is present the task is set in idle mode from the &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt;. In case one or more new events are available the &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; wakes up the task. The used &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; mechanism for event signaling can be different. But often a message queue is used. Events might be stored in the event queue from various sources. E.g. from within another task or from inside an interrupt service routine from a timer which is shown in the code below. This design can be realised with every real-time operating system. Mainly the exact syntax differs from &lt;abbr title=&quot;Operating System&quot;&gt;OS&lt;/abbr&gt; to &lt;abbr title=&quot;Operating System&quot;&gt;OS&lt;/abbr&gt;.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;How to use state machines with a real-time operating system&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;how_to_use_state_machines_with_a_real-time_operating_system&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;1-1605&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit2&quot; id=&quot;simple_state_machine&quot;&gt;Simple State Machine&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
&lt;a href=&quot;https://www.sinelabore.com/lib/exe/detail.php/wiki/howto/rtos-sm.png?id=wiki%3Ahowto%3Artos&quot; class=&quot;media&quot; title=&quot;wiki:howto:rtos-sm.png&quot;&gt;&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/rtos-sm.png?w=400&amp;amp;tok=60d990&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;Simple state machine using a timer to toggle between two states&quot; alt=&quot;Simple state machine using a timer to toggle between two states&quot; width=&quot;400&quot; /&gt;&lt;/a&gt; The simple state machine below reacts on a cyclic timer. It just toggles between the two states &lt;code&gt;SA&lt;/code&gt; and &lt;code&gt;SB&lt;/code&gt;. It prints some text as demo when enter or leaving a state and when the transition takes place. In more complex systems more than one timer might be needed. If different timers are needed different timeout events and timers can be setup easily. See below.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Simple State Machine&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;simple_state_machine&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;1606-2111&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit3&quot; id=&quot;setup_the_system&quot;&gt;Setup the system&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
This simple main code creates a task a queue and a timer and then starts the &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; scheduler.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    prvInitialiseHeap&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    vTraceEnable&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; TRC_START &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    xTaskCreate&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;tA&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;TA&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1000&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/*Bytes stack*/&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; NULL &lt;span class=&quot;coMULTI&quot;&gt;/* no parameters */&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
        tskIDLE_PRIORITY &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; NULL&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
    &lt;span class=&quot;coMULTI&quot;&gt;/* Create the queue. */&lt;/span&gt;
    queueHandle &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; xQueueCreate&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;sizeof&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;USER_EVENT_T&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    timerHandle &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; xTimerCreate&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Timer&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;	&lt;span class=&quot;coMULTI&quot;&gt;/* name for debugging */&lt;/span&gt;
        &lt;span class=&quot;nu0&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                           &lt;span class=&quot;coMULTI&quot;&gt;/* ticks -&amp;gt; 1s */&lt;/span&gt;
        &lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                           &lt;span class=&quot;coMULTI&quot;&gt;/* true = repetitive */&lt;/span&gt;
        NULL&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;                           &lt;span class=&quot;coMULTI&quot;&gt;/* The timer&#039;s ID is not used. */&lt;/span&gt;
        timerCallback&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;                 &lt;span class=&quot;coMULTI&quot;&gt;/* The function executed when the timer expires. */&lt;/span&gt;
&amp;nbsp;
    xTimerStart&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;timerHandle&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;        &lt;span class=&quot;coMULTI&quot;&gt;/* The scheduler has not started so use a block time of 0. */&lt;/span&gt;
&amp;nbsp;
    vTaskStartScheduler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Setup the system&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;setup_the_system&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;2112-3024&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit4&quot; id=&quot;ta_task&quot;&gt;TA task&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
The tasks waits blocking for elements to appear in the queue. If data is present in the queue we dequeue it and call the state machine.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; tA&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; xTimerHandle&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;coMULTI&quot;&gt;/* Avoid compiler warnings resulting from the unused parameter. */&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;xTimerHandle&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    USER_EVENT_T data &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt; SM_NO_MSG &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;TA task.&lt;span class=&quot;es1&quot;&gt;\r&lt;/span&gt;&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
        &lt;span class=&quot;coMULTI&quot;&gt;/* Wait until something arrives in the queue - this task will block
        indefinitely. */&lt;/span&gt;
&amp;nbsp;
        &lt;span class=&quot;co1&quot;&gt;// call once to init&lt;/span&gt;
        sm&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instDataSM&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;data&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
        &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            xQueueReceive&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;queueHandle&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;data&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; portMAX_DELAY&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;        
            sm&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instDataSM&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;data&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;TA task&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;ta_task&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;3025-3743&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit5&quot; id=&quot;timer&quot;&gt;Timer&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
Each timer has a callback function called from the &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; in case of a timeout happened. In the timer handler we simply enqueue a message with a timeout event (here &lt;code&gt;evTimeout&lt;/code&gt;). We decided to sent some data in addition to the event. Therefore we defined an own data type (USER_EVENT_T) that is sent to the state machine. Otherwise it would be possible to just sent the event itself.
&lt;/p&gt;

&lt;p&gt;
For clearness it is good to use some kind of guideline how events should be named. Here we call it &lt;code&gt;evTimeout&lt;/code&gt;. If you have multiple timers call them e.g. according to their purpose.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* This is the software timer callback function. This
    callback function will execute if the timer expires */&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; timerCallback&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TimerHandle_t xTimerHandle&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; cnt &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    cnt&lt;span class=&quot;sy0&quot;&gt;++;&lt;/span&gt;
&amp;nbsp;
    USER_EVENT_T data &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;evTimeout&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; cnt&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// evTimeout is used in the state diagram&lt;/span&gt;
&amp;nbsp;
    xQueueSend&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;queueHandle&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;data&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; 0U&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Timer&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;timer&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;3744-4680&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit6&quot; id=&quot;wrap-up&quot;&gt;Wrap-up&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
We showed how to use state machines in the context of FreeRTOS. This pattern can be universally used with any other &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; too. Using this pattern allows a very flexibly system design and allows to design robust easy to understand  real-time embedded systems. The relevant files are available here: &lt;a href=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/freertos-code.zip&quot; class=&quot;media mediafile mf_zip&quot; title=&quot;wiki:howto:freertos-code.zip (6.6 KB)&quot;&gt;freertos-code.zip&lt;/a&gt;
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;https://www.sinelabore.com/doku.php/tag/freertos?do=showtag&amp;amp;tag=FreeRTOS&quot; class=&quot;wikilink1&quot; title=&quot;tag:freertos&quot; rel=&quot;tag&quot;&gt;FreeRTOS&lt;/a&gt;,
	&lt;a href=&quot;https://www.sinelabore.com/doku.php/tag/rtos?do=showtag&amp;amp;tag=RTOS&quot; class=&quot;wikilink1&quot; title=&quot;tag:rtos&quot; rel=&quot;tag&quot;&gt;RTOS&lt;/a&gt;,
	&lt;a href=&quot;https://www.sinelabore.com/doku.php/tag/pattern?do=showtag&amp;amp;tag=Pattern%5D&quot; class=&quot;wikilink1&quot; title=&quot;tag:pattern&quot; rel=&quot;tag&quot;&gt;Pattern]&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Wrap-up&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;wrap-up&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:6,&amp;quot;range&amp;quot;:&amp;quot;4681-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Sun, 12 Mar 2023 17:18:44 +0000</pubDate>
        </item>
        <item>
            <title>Static Code Checkers</title>
            <link>https://www.sinelabore.com/doku.php/wiki/howto/static_code_checkers</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;static_code_checkers&quot;&gt;Static Code Checkers&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
Static program analysis is the analysis of computer software performed without executing any programs. Often the use of static code checkers is required in critical applications of different sort. 
Generally speaking the source code generated by sinelabore should create no or little issues. But some points should be considered (see below).
&lt;/p&gt;

&lt;p&gt;
One of the well known tools in this category is PC-lint from Gimpel Soft (&lt;a href=&quot;https://www.gimpel.com&quot; class=&quot;urlextern&quot; title=&quot;https://www.gimpel.com&quot; rel=&quot;ugc nofollow&quot;&gt;https://www.gimpel.com&lt;/a&gt;).
Another free one is &lt;code&gt;cppcheck&lt;/code&gt;. Generated C/C++ code is regularly tested with cppcheck and its misra checker. Details about cppcheck can be found here: &lt;a href=&quot;https://cppcheck.sourceforge.io/manual.pdf&quot; class=&quot;urlextern&quot; title=&quot;https://cppcheck.sourceforge.io/manual.pdf&quot; rel=&quot;ugc nofollow&quot;&gt;https://cppcheck.sourceforge.io/manual.pdf&lt;/a&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Static Code Checkers&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;static_code_checkers&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;1-677&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;c-code&quot;&gt;C-Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
For C-code the following parameter settings are suggested in the &lt;code&gt;codegen.cfg&lt;/code&gt; file:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;#It is recommended to set the following parameters to include the standard types.
#Additional include in the validate h file to provide data types
AdditionalValidateIncludes=#include &amp;lt;stdint.h&amp;gt;\n#include &amp;lt;stdbool.h&amp;gt;
#
# Include file which can be used to define the simple data types
AdditionalMachineInclude=#include &amp;lt;stdint.h&amp;gt;\n#include &amp;lt;stdbool.h&amp;gt;
#Setting the used types to avoid problems with boolean comparisons ...

UINT8 = uint8_t
UINT16 = uint16_t
BOOL=bool
BOOL_TRUE=true
BOOL_FALSE=false


#Avoid issues about not used variable
ReturnEventProcessed=yes

UseUnderlineForIncludeProtection=no&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;C-Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;c-code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;678-1402&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit3&quot; id=&quot;c_code&quot;&gt;C++ Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
It is recommended to use the newer features of C++11.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;#Avoid issues about not used variable
ReturnEventProcessed=yes

#Avoid issues of not initialised variables in the ctor
CallInitializeInCtor = yes

#This enables the uses of array ...
UseEnumBaseTypes = YES

EnumBaseTypeForEvents = std::uint16_t
EnumBaseTypeForStates = std::uint32_t

ReturnAndProcessEventTypeOfStateMachine = std::uint16_t
InitializedFlagTypeOfStateMachine = std::uint16_t

UseUnderlineForIncludeProtection=no&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;C++ Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;c_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;1403-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Thu, 09 Jun 2022 18:06:06 +0000</pubDate>
        </item>
        <item>
            <title>How to use state machines with VxWorks</title>
            <link>https://www.sinelabore.com/doku.php/wiki/howto/vxworks</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;how_to_use_state_machines_with_vxworks&quot;&gt;How to use state machines with VxWorks&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
State machines can be used in various places of your system. In this example you will learn how to use a state machine in the context of VxWorks. VxWorks is a market-leading real-time operating system (&lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt;) used in many different applications since many years. You can follow this tutorial by using the &lt;a href=&quot;https://forums.windriver.com/t/vxworks-software-development-kit-sdk/43&quot; class=&quot;urlextern&quot; title=&quot;https://forums.windriver.com/t/vxworks-software-development-kit-sdk/43&quot; rel=&quot;ugc nofollow&quot;&gt;VxWorks Software Development Kit&lt;/a&gt; on of of the supported platforms. We use QEMU (x86-64) running on a Debian host.
&lt;/p&gt;

&lt;p&gt;
In the most typical design, each state machine runs in the context of an own task. The design of the fully running example is shown in the following figure and available for download at the end of the article.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://www.sinelabore.com/lib/exe/detail.php/wiki/howto/vxworks_design.svg?id=wiki%3Ahowto%3Avxworks&quot; class=&quot;media&quot; title=&quot;wiki:howto:vxworks_design.svg&quot;&gt;&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/vxworks_design.svg?w=400&amp;amp;tok=3f10ed&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;Using state machines with a real-time operating system&quot; alt=&quot;Using state machines with a real-time operating system&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Each task executes a state machine (often called active object) in an endless while loop. The tasks wait for new events to be processed from the state machine. In case no event is present the task is set in idle mode from VxWorks. In case one or more new events are available the VxWorks wakes up the task. The used VxWorks mechanism for event signaling can be different. But often a message queue is used. Events might be stored in the event queue from various sources. E.g. from within another task or from inside an interrupt service routine from a timer. This design can be realised with every real-time operating system. Mainly the exact syntax differs from &lt;abbr title=&quot;Operating System&quot;&gt;OS&lt;/abbr&gt; to &lt;abbr title=&quot;Operating System&quot;&gt;OS&lt;/abbr&gt;.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;How to use state machines with VxWorks&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;how_to_use_state_machines_with_vxworks&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;1-1530&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit2&quot; id=&quot;simple_state_machine_used_for_evaluation&quot;&gt;Simple state machine used for evaluation&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
&lt;a href=&quot;https://www.sinelabore.com/lib/exe/detail.php/wiki/howto/vxworks_sm.png?id=wiki%3Ahowto%3Avxworks&quot; class=&quot;media&quot; title=&quot;wiki:howto:vxworks_sm.png&quot;&gt;&lt;img src=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/vxworks_sm.png?w=600&amp;amp;tok=01386d&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;Simple state machine&quot; alt=&quot;Simple state machine&quot; width=&quot;600&quot; /&gt;&lt;/a&gt; This state machine is a representative of a simplified control task. The state machine was designed with the built-in state machine editor. And the state machine code was completely generated.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Simple state machine used for evaluation&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;simple_state_machine_used_for_evaluation&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;1531-1837&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit3&quot; id=&quot;setting_up_the_system&quot;&gt;Setting up the system&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
This simple main code creates two tasks, a message queue, the timeout timer and the state machine.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdint.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;vxWorks.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;taskLib.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;msgQLib.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;time.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;state_machine_ext.h&amp;quot;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;state_machine.h&amp;quot;&lt;/span&gt;
&amp;nbsp;
TASK_ID tid1&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;tid2&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;tidLowPrio&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
MSG_Q_ID qid&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
timer_t timerID&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; itimerspec value&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; ovalue&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
STATE_MACHINE_INSTANCEDATA_T smInstance &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; STATE_MACHINE_INSTANCEDATA_INIT&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// Helper to start timer from state machine.&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// In practise you might use a more sophisticated routine considering multiple timers ...&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; startTimer&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Start timer!&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    timer_settime &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;timerID&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; TIMER_RELTIME&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;value&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;ovalue&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// helper to stop timer&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; stopTimer&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Stop timer!&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    timer_cancel&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;timerID&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
    qid &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; msgQCreate&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* msg len in byte */&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;MSG_Q_FIFO&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co1&quot;&gt;// create a cyclic timer for demo purposes used in the state machine&lt;/span&gt;
    timer_create &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;CLOCK_REALTIME&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; NULL&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;timerID&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    timer_connect &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;timerID&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;VOIDFUNCPTR&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;timerhandler&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; NULL&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    value.&lt;span class=&quot;me1&quot;&gt;it_value&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tv_nsec&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; 
    value.&lt;span class=&quot;me1&quot;&gt;it_value&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tv_sec&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; 
    value.&lt;span class=&quot;me1&quot;&gt;it_interval&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tv_nsec&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// 500ms&lt;/span&gt;
    value.&lt;span class=&quot;me1&quot;&gt;it_interval&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tv_sec&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co1&quot;&gt;// init state var once&lt;/span&gt;
    state_machine&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;smInstance&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; STATE_MACHINE_NO_MSG &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    tid1 &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; taskSpawn&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;/task1&amp;quot;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;107&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; VX_NO_STACK_FILL &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;2000&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;FUNCPTR&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;task1&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    tid2 &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; taskSpawn&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;/task2&amp;quot;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;106&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; VX_NO_STACK_FILL &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;2000&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;FUNCPTR&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;task2&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    tidLowPrio &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; taskSpawn&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;/taskidle&amp;quot;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;255&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; VX_NO_STACK_FILL &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;2000&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;FUNCPTR&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;lowPriTask&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
    &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;init finished!&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        taskDelay &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;CLOCKS_PER_SEC&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;  
&amp;nbsp;
    taskSuspend &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Setting up the system&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;setting_up_the_system&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;1838-3659&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit4&quot; id=&quot;vxworks_task_1&quot;&gt;VxWorks Task 1&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
The &lt;code&gt;task1&lt;/code&gt; waits blocking for elements to appear in the queue. If data is present in the queue we dequeue it and call the state machine.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; task1&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt; 
    &lt;span class=&quot;co2&quot;&gt;#define BUF_LEN 5&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; buf&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;BUF_LEN&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;task 1 started!&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        msgQReceive&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;qid&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; buf&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;WAIT_FOREVER&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        state_machine&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;smInstance&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;buf &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;VxWorks Task 1&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;vxworks_task_1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;3660-4054&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit5&quot; id=&quot;vxworks_task_2&quot;&gt;VxWorks Task 2&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
For simplicity &lt;code&gt;task2&lt;/code&gt; sends events to &lt;code&gt;task1&lt;/code&gt; via the created message queue. In practise also from timers or interrupt service routines events might be sent.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; msgs&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;evStart&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;STATE_MACHINE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; STATE_MACHINE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;STATE_MACHINE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;STATE_MACHINE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
    STATE_MACHINE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;STATE_MACHINE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;STATE_MACHINE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;evStop&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;evStart&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;evStop&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;evShutdown&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
    STATE_MACHINE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;STATE_MACHINE_NO_MSG&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; task2&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt; 
    &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;task 2 started!&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; i&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;sizeof&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msgs&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        msgQSend&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;qid&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;msgs&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;WAIT_FOREVER&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;MSG_PRI_NORMAL&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        taskDelay&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;CLOCKS_PER_SEC&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;VxWorks Task 2&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;vxworks_task_2&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;4055-4723&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit6&quot; id=&quot;generated_output_on_the_qemu_console&quot;&gt;Generated output on the qemu console&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
The following output is generated from the above code. Note that a hierarchical state machine with history is used.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;[vxWorks *]# example.vxe
Launching process &amp;#039;example.vxe&amp;#039; ...
Process &amp;#039;example.vxe&amp;#039; (process Id = 0xffff800000312010) launched.
Enter STOP
In STOP
task 1 started!
task 2 started!
In STOP
Exit STOP
Start timer!
Enter RUN
Enter Slow
init finished!
In RUN
Exit Slow
Enter Fast
In RUN
Exit Fast
Enter Slow
In RUN
In RUN
Exit Slow
Enter Fast
...
In RUN
Exit Slow
Exit RUN
Stop timer!
Enter STOP
In STOP
Exit STOP
Start timer!
Enter RUN
Enter Slow
In RUN
Exit Slow
Enter Fast
In RUN
Exit Fast
Enter Slow
In RUN
Exit Slow
Exit RUN
Stop timer!
Enter STOP
In STOP
Exit STOP
Entering Final&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Generated output on the qemu console&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generated_output_on_the_qemu_console&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:6,&amp;quot;range&amp;quot;:&amp;quot;4724-5486&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit7&quot; id=&quot;wrap-up&quot;&gt;Wrap-up&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
We showed how to use state machines in the context of VxWorks. This pattern can be universally used with any other &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; too. Using this pattern allows a very flexibly system design and allows to design robust and easy to understand  real-time embedded systems. The relevant files &lt;a href=&quot;https://www.sinelabore.com/lib/exe/fetch.php/wiki/howto/vxworks_example.zip&quot; class=&quot;media mediafile mf_zip&quot; title=&quot;wiki:howto:vxworks_example.zip (10.6 KB)&quot;&gt;are available here.&lt;/a&gt;
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;https://www.sinelabore.com/doku.php/tag/vxworks?do=showtag&amp;amp;tag=VxWorks&quot; class=&quot;wikilink1&quot; title=&quot;tag:vxworks&quot; rel=&quot;tag&quot;&gt;VxWorks&lt;/a&gt;,
	&lt;a href=&quot;https://www.sinelabore.com/doku.php/tag/rtos?do=showtag&amp;amp;tag=RTOS&quot; class=&quot;wikilink1&quot; title=&quot;tag:rtos&quot; rel=&quot;tag&quot;&gt;RTOS&lt;/a&gt;,
	&lt;a href=&quot;https://www.sinelabore.com/doku.php/tag/pattern?do=showtag&amp;amp;tag=Pattern%5D&quot; class=&quot;wikilink1&quot; title=&quot;tag:pattern&quot; rel=&quot;tag&quot;&gt;Pattern]&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Wrap-up&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;wrap-up&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:4,&amp;quot;secid&amp;quot;:7,&amp;quot;range&amp;quot;:&amp;quot;5487-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Wed, 08 Mar 2023 18:32:44 +0000</pubDate>
        </item>
    </channel>
</rss>
