Difference between revisions of "Example Xenomai Timer"

From wiki.emacinc.com
Jump to: navigation, search
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{todo| FinalDraft (10.06.2015-12:58->KY+)|Klint Youngmeyer| project=OE 5.0,KY,FinalDraft }}
+
{{todo| Complete (10.06.2015-12:58->KY+)(11.13.2015-13:15->MG+)|Klint Youngmeyer| project=OE 5.0,KY,MG,MD,Complete }}
 
{{#seo:
 
{{#seo:
 
|title=Example xenomai timer
 
|title=Example xenomai timer
Line 16: Line 16:
 
===Hardware Requirements===
 
===Hardware Requirements===
  
The <code>xenomai-timer</code> C example project will run on an i586 system with a real-time Xenomai kernel.
+
The <code>xenomai-timer</code> C example project will run on an i586 system with a Xenomai real-time enabled kernel.
  
 
=== Building the Project ===
 
=== Building the Project ===
  
There are some options for building this example project: Qt Creator or CMake.
+
There are two options for building this example project: Qt Creator or CMake.
  
 
==== Qt Creator ====
 
==== Qt Creator ====
Line 30: Line 30:
 
# Select the "Xenomai Timer" icon. The example wizard will now request the build directory for the project. It is not recommended to use the default location. The following is a reasonable location on an EMAC LDC.
 
# Select the "Xenomai Timer" icon. The example wizard will now request the build directory for the project. It is not recommended to use the default location. The following is a reasonable location on an EMAC LDC.
 
#:{{clo}}/home/developer/Projects/xenomai-timer{{clos}}
 
#:{{clo}}/home/developer/Projects/xenomai-timer{{clos}}
# The next window will prompt to run CMake. Click the "Run CMake" button.
+
# The next window will prompt you to run CMake. Click the "Run CMake" button.
# Click "Finish" (Note: This project may not build for the Desktop kit, unless the Xenomai libraries are installed for your system.)
+
# Click "Finish" (Note: This project may not build for the Desktop kit, unless the Xenomai libraries are installed for your host system.)
 
# Click the "Projects" icon in the left column, then click "Add Kit" and select "OE 5.x x86".
 
# Click the "Projects" icon in the left column, then click "Add Kit" and select "OE 5.x x86".
# The default build location is fine, click Next.
+
# The default build location is fine; click Next.
# Enter the following into the Arguments field, then click "Run CMake."
+
# Enter the following into the Arguments field, then click, "Run CMake."
 
#:{{clo}}-DARCH:STRING=x86{{clos}}
 
#:{{clo}}-DARCH:STRING=x86{{clos}}
 
# Click Finish.
 
# Click Finish.
Line 48: Line 48:
 
#:{{cli | username=developer | hostname=ldc | cd ~/Projects }}
 
#:{{cli | username=developer | hostname=ldc | cd ~/Projects }}
 
# Copy the xenomai-timer example to the current directory.
 
# Copy the xenomai-timer example to the current directory.
#:{{cli | username=developer | hostname=ldc | cp -r /opt/emac/5.0/sysroots/x86_64-emacsdk-linux/usr/demos/EMAC-Examples/xenomai-timer/ . }}
+
#:{{cli | username=developer | hostname=ldc | cp -r /opt/emac/5.X/sysroots/x86_64-emacsdk-linux/usr/demos/EMAC-Examples/xenomai-timer/ . }}
 
# Change directory to the project directory.
 
# Change directory to the project directory.
 
#:{{cli | username=developer | hostname=ldc | cd xenomai-timer }}
 
#:{{cli | username=developer | hostname=ldc | cd xenomai-timer }}
# Create build directory for cross-compilation, then change directory into it.
+
# Create the build directory for cross-compilation, then change directory into it.
 
#:{{cli | username=developer | hostname=ldc | mkdir xenomai-timer-build-OE5-x86 }}
 
#:{{cli | username=developer | hostname=ldc | mkdir xenomai-timer-build-OE5-x86 }}
 
#:{{cli | username=developer | hostname=ldc | cd xenomai-timer-build-OE5-x86 }}
 
#:{{cli | username=developer | hostname=ldc | cd xenomai-timer-build-OE5-x86 }}
Line 64: Line 64:
 
#:{{cli |  hostname=x86 | cd /tmp }}
 
#:{{cli |  hostname=x86 | cd /tmp }}
 
# Run the program.
 
# Run the program.
#:{{cli | hostname=x86 | ./timer }}
+
{{clo | indent=3}}
 
+
{{clio|hostname=x86|pwd=/tmp|./timer}}
 
+
Starting Timer Test: Period = 100000000 ns<br />
===Using <code>timer</code>===
+
Press Ctrl-C to exit<br />
 
+
testtask periodic loop: count=1<br />
The <code>timer</code> program is executed from the console.
+
testtask periodic loop: count=2<br />
 
+
testtask periodic loop: count=3<br />
<code>./timer</code>
+
testtask periodic loop: count=4<br />
 +
testtask periodic loop: count=5<br />
 +
{{clos}}
  
 
The program will continue running until it is manually halted with a CTRL-C.
 
The program will continue running until it is manually halted with a CTRL-C.
 
 
 
==Summary==
 
==Summary==
  
 
The <code>timer</code> C example project demonstrates how to use the xenomai timer.
 
The <code>timer</code> C example project demonstrates how to use the xenomai timer.

Latest revision as of 11:22, 8 June 2016

TODO: {{#todo: Complete (10.06.2015-12:58->KY+)(11.13.2015-13:15->MG+)|Klint Youngmeyer|OE 5.0,KY,MG,MD,Complete}}

This is a guide to the xenomai-timer C example project included in the EMAC OE SDK.

This project demonstrates how to build the real-time software timer.

The timer project builds one executable: timer.

Building and Running the Project Files

Hardware Requirements

The xenomai-timer C example project will run on an i586 system with a Xenomai real-time enabled kernel.

Building the Project

There are two options for building this example project: Qt Creator or CMake.

Qt Creator

This process will show how to build the project using Qt Creator. For further information on using Qt Creator, please see Getting Started With Qt Creator.

  1. Open Qt Creator using the "EMAC IDE" button on the Ubuntu sidebar.
  2. Click the "Example" button on the left of the page. This will bring up a list of all included examples.
  3. Select the "Xenomai Timer" icon. The example wizard will now request the build directory for the project. It is not recommended to use the default location. The following is a reasonable location on an EMAC LDC.
    /home/developer/Projects/xenomai-timer
  4. The next window will prompt you to run CMake. Click the "Run CMake" button.
  5. Click "Finish" (Note: This project may not build for the Desktop kit, unless the Xenomai libraries are installed for your host system.)
  6. Click the "Projects" icon in the left column, then click "Add Kit" and select "OE 5.x x86".
  7. The default build location is fine; click Next.
  8. Enter the following into the Arguments field, then click, "Run CMake."
    -DARCH:STRING=x86
  9. Click Finish.
  10. Ensure that the "OE 5.x x86" kit is selected by clicking the computer icon on the lower left, then click Build (the hammer icon).
  11. Add the target device to the Qt Creator devices by following the instructions on this page, starting at point 9.
  12. Click the Run button on the bottom left (green arrow).

CMake

This process will show how to build the project using CMake.

  1. Navigate to the Projects directory.
    developer@ldc:~# cd ~/Projects
  2. Copy the xenomai-timer example to the current directory.
    developer@ldc:~# cp -r /opt/emac/5.X/sysroots/x86_64-emacsdk-linux/usr/demos/EMAC-Examples/xenomai-timer/ .
  3. Change directory to the project directory.
    developer@ldc:~# cd xenomai-timer
  4. Create the build directory for cross-compilation, then change directory into it.
    developer@ldc:~# mkdir xenomai-timer-build-OE5-x86
    developer@ldc:~# cd xenomai-timer-build-OE5-x86
  5. Run CMake.
    developer@ldc:~# cmake .. -DARCH:STRING=x86
  6. Build the project.
    developer@ldc:~# make
  7. Copy the executable to the target board. Substitute the IP address 10.0.2.41 with the IP address of your target board.
    developer@ldc:~# scp timer root@10.0.2.41:/tmp
  8. Open a terminal on the target board, using SSH, serial, or a dedicated screen and keyboard.
  9. Navigate to the /tmp directory.
    root@x86:~# cd /tmp
  10. Run the program.
root@x86:/tmp# ./timer

Starting Timer Test: Period = 100000000 ns
Press Ctrl-C to exit
testtask periodic loop: count=1
testtask periodic loop: count=2
testtask periodic loop: count=3
testtask periodic loop: count=4
testtask periodic loop: count=5

The program will continue running until it is manually halted with a CTRL-C.

Summary

The timer C example project demonstrates how to use the xenomai timer.