Command Line Tools QUARC Monitor navigation bar

Table of Contents > QUARC > User's Guide

QUARC Console - Model Standard I/O

This section describes the QUARC Console, a tool you can use to monitor a model's standard I/O. The QUARC Console is a similar interface to the Windows Command Prompt or the Linux Terminal and simply displays anything printed to stdout and stderr by the real-time code. For example, the real-time code prints the arguments passed to it when it loads, by default, as well as its actual sample time. The QUARC Console also accepts keyboard input and sends it to stdin of the real-time code. This property of the QUARC Console makes it a fast and easy way of monitoring a model and looking at its standard I/O while it runs on a local or remote QUARC target. The QUARC Console also displays informative messages when a model is downloaded to the target, loaded on the target, or the model terminates. These notifications are generated by the Console itself and not the real-time code. Informative notifications are preceded by a string of '-' characters. This page is divided into two sections as listed below.

The first section describes different ways of opening a QUARC Console while the second section describes the properties, features and main applications of this tool.

Opening a QUARC Console

The QUARC Console can be opened in a number of convenient ways. Please use the following list to refer to each method's description:

You can open a console using the QUARC menu of any Simulink diagram. The Console item of the QUARC menu, depicted below, can be used to open a console for the current model. The target URI for the model will be used to communicate with the target. Only the standard I/O of the model's real-time code on the associated target will be monitored.

For more information about this option please refer to the Console section on the QUARC Menu page.

The Console for all ... option of the QUARC Menu can also be used to open a console. Using this option will open a console for all the models running on the target identified by the target URI of the current model. For more information about using this option please refer to the Console for all section on the QUARC Menu page.

Opening a Console using the Windows Start Menu

You can open a console using the Windows Start menu by selecting Start/All Programs/Quanser/QUARC/Console. This will open a console window for the target identified by the default settings of the Console for Target Start menu item. This menu item is available under Start/All Programs/Quanser/QUARC/Console for Target and can be used to manually specify the target for which the console should open. A window as the one depicted below opens when the Console for Target menu item is selected.

You must enter the URI of the target for which you want to monitor the models' standard I/O in the Target URI field of this window. Once you enter the target URI and click on Console, a QUARC Console window will open in which you will be able to monitor the standard I/O of all the models running on the target you specified when filling in the Target URIpan field. Please keep in mind that if the box next to "Use these parameters as the defaults for this target type" is checked, the target URI you enter will become the default for the Start menu Console commands. As a result, this target URI will be used to communicate with the target when you choose the Console Start menu option. If you do not wish the target URI you are entering to become the default make sure this box is not checked.

If you would like to completely change the default settings for this option simply enter your new default target URI in the appropriate field of the window depicted above, check the box next to "Use these parameters as the defaults for this target type" and click on Console.

Opening a Console using Windows Explorer

The Windows Explorer interface can also be used to open a QUARC Console. When the real-time code for a Simulink model is generated using QUARC, a "QUARC Executable" is created in MATLAB's Current Directory. As explained in the Using Windows Explorer to Manage Models reference page, right-clicking on each of these executable files opens a context menu that includes the items: Console and Console for target. Refer to the Console and Console for target sections of the Using Windows Explorer to Manage Models reference page for an explanation of these two options respectively.

Opening a Console using the QUARC Tray Icon

Once you install QUARC on your computer a QUARC icon will appear in the Windows system tray. Right-clicking on this tray icon provides a menu with options including Console ... and Stop All, as shown below:

The Console ... option of this menu can also be used to open a QUARC Console. Simply click on the Console ... option and a Console window will open. Please keep in mind that this particular QUARC Console is designed to work on the target machine. When using the QUARC tray icon to open a console, the tray application checks to see which URIs are currently being used by the QUARC Target Manager and picks the first one out of the list.

Opening a Console using the QUARC Command Line Tools

If you are using the QUARC Command Line Tools to interact with your models, opening a QUARC Console is as easy as including the -c option on the command line for the quarc_run command. Including this option will cause a Console window to open in which you can monitor the standard I/O of the model you specify on the command line. If the -d option is not specified to open up a dialog for entering the target URI then the target URI must be specified on the command line as well using the -t <uri> option. Please refer to the -c section of the QUARC Command Line Tools reference page for more information about using this option to open a Console.

Opening a Console using QUARC-MATLAB Functions

If you are using the QUARC MATLAB Functions to interact with your models, opening a QUARC Console is as easy as running the qc_model_console function. There are different options available to you, such as opening a console for all models running on the given target or opening a model-specific console. Please refer to the qc_model_console page for details.

Properties and Applications

In order to display the standard I/O of a model, the QUARC Console connects directly to the target where the code generated from the model will run. This property of the QUARC Console makes it a reliable source of information in situations where the user needs real-time updates about what is happening on the target.

The QUARC Console can also be used as a great debugging tool when writing S-Functions. You can simply place printf commands in different parts of your code, build the model, open a Console for the model and run the model. Any printf commands that are executed will print their output to the QUARC Console. Note, however, that the output is buffered for efficiency, so a fflush(stdout) call is needed after the printf if you want the output to appear immediately.

The QUARC Console is also handy for debugging any errors that occur before Simulink manages to connect to the model. For example, if an invalid model URI is specified then the model will not be able to listen on the model URI and Simulink will not be able to connect the model and external mode. The QUARC Console, however, allows you to see why Simulink cannot connect because the error message will be printed to the Console.

Not only does the QUARC Console display anything printed to stdout and stderr, it also sends anything you type in the console window to the stdin stream. The "Enter" key must be pressed before the text is sent to stdin. This feature could be used to create an interface in which the user interacts with the model via the QUARC Console. Such an interface could be done by creating an S-Function which prints the available options to stdout. The user can then respond by typing in the Console and pressing Enter. The stdin stream can now be parsed in the same S-Function and the selected course of action taken. Such an S-function would best be run in an asynchronous thread to avoid interfering with the sample rate of the main diagram.

Another powerful property of the QUARC Console is that you can open one for remote targets, regardless what type of QUARC target it is. This is particularly useful for monitoring models that are running on embedded systems where the features of a PC are not available. You can simply open a console window for the remote target.

 

navigation bar