RTC Website

section 0.4 companion and outline

This page contains companion resources and an outline for section 0.4 of the book An Introduction to Real-Time Computing for Mechanical Engineers, and it therefore lacks most of section 0.4’s contents. While some sections of the book are fully available on this site, many are not. Please consider purchasing a copy from the MIT Press.

Getting started with C

A sandbox for C

DX

When starting to program in a new language, it is important to have an environment in which you can experiment—a sort of sandbox. We can use the development environment set up in section 0.2.

In the hello-world program of subsection 0.2.1, we used a Windows C compiler to build an executable that can run on the development computer. We will continue using this compiler for building and running C programs in our sandbox. However, in the lab exercises, we will use the “Cross GCC” cross-compiler, which allows a compiled program to run on the ARM-based target computer (Instruments 2018).

Select FileNewC Project and enter sandbox-1 as the project name. Select the project type ExecutableHello World ANSI C Project and the Windows toolchain1 (e.g., MinGW GCC). Finally, click Finish to create the project, which should appear in Project Explorer.

Expand the project and open sandbox-1/src/sandbox-1.c in the editor. This is similar to our hello-world project, and it makes a nice starting point for exploring C. Edit sandbox-1.c to print "Hello sandbox" and save it. Build (i.e., Ctrl + b) the project. For inane reasons,2 the first two build attempts may fail. Once building succeeds, Debug/sandbox-1.exe will be ready to run.

To run your new executable on the development computer, create a new Run Configuration by opening the dialog with Ctrl + r, selecting C/C++ Application, and clicking enrc. In the C/C++ Application box, enter Debug/sandbox-1.exe. Now just click Run. In the Console, Hello sandbox should display.

Now you can edit sandbox-1.c in any way you like, build it, and run it with your new Run Configuration. This process can be repeated to generate additional programs.

Online resources for Section 0.4

No online resources.

Instruments, National. 2018. “C Support for myRIO 6.0 User Guide.” Web. https://www.ni.com/en/support/downloads/software-products/download.c-support-for-myrio.html#329806.
Project, MinGW, and Community. 2021. “Minimalist GNU for Windows (MinGW).” https://www.mingw-w64.org/.

  1. The Windows C compiler/toolchain may vary by specific D1 development environment. For instance, for D1a, the MinGW GNU Compiler Collection (GCC) C compiler is used (Project and Community 2021).↩︎

  2. Our version of Eclipse has a bug that may cause the first two builds to fail for a new project. After it builds successfully, this project should build fine thereafter.↩︎