Start of trail Scan navigation bar

Table of Contents

Print

Prints to the QUARC Console or the MATLAB Command Window.

Library

QUARC Targets/User Interface/Standard I/O

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

qc_open_library('quarc_library/User Interface/Standard I//O')

Description

Print

In normal simulation, the Print block prints formatted text to the Matlab command window, much like fprintf prints to a file. In real-time code, it prints to the QUARC Console. The block may be used anywhere in the diagram, including in an asynchronous thread.

For a description of the format strings, refer to Format Strings for Printing .

This block formats its inputs according to the given format string and then writes the formatted textual result to the console. It attempts to store all of the formatted text in a stream buffer prior to writing it to the console. It uses the UTF-8 character format for the text. If there is enough room available in the stream buffer then it stores the text in the buffer and returns immediately. If the Optimize parameter is set to minimize latency then it will also flush the stream each time that it executes. Otherwise, it only flushes the stream buffer to the underlying console when the stream buffer is full. The size of the stream buffer is 512 bytes.

If an error occurs, then it returns a negative error code at its err output.

This block may wait while attempting to flush the stream buffer. All the text will be consumed and the number of code units written is returned at its err output. Some of the text may remain in the stream buffer and not be sent until the next time the Stream Print block is called or there is no more room available in the stream buffer. If an error occurs then the error code is returned at its err output.

The formatted text is treated as an atomic unit. It will never write part of the text to the stream buffer. These semantics make it much easier to deal with streams in Simulink where it is difficult to deal with "parts" of text. Note that largest string of formatted text must be no more than 512 bytes or -QERR_STREAM_BUFFER_TOO_SMALL is returned by the err output.

Special escape sequences may be issued for the QUARC Console to change the colour of text, use simple line drawing characters for making boxes, clear the screen, position the cursor and more. Refer to Console Virtual Terminal Sequences for details.

Input Ports

...

The input ports contain the data to be formatted. The number of input ports is determined by the number of format specifiers, such as %lg, in the specified format string. The %n format specifier does not produce an input port. Instead it causes an output port to be created. All other valid format specifiers cause corresponding input ports to be created. Variable-sized field widths, precisions and code unit specifiers also cause input ports to be created in order to specify the field width, precision or maximum number of code units. Inputs corresponding to string or variable dimension format specifiers may be variable-size signals. See Variable-Size Signals for more information on variable-size signals.

Output Ports

...

The first output ports, with the exception of the last two ports, are used for %n specifiers in the format string, which produce the number of code units processed up to that point in the format string.

flds

An int32 value indicating the number of fields from the format string that were written to the stream buffer successfully and fully. This number may be less than the number of fields defined in the format string if the maximum number of code units was reached before all the fields were written to the stream buffer. If an error occurs, then this value indicates the number of fields that could be written successfully, which may assist in locating the source of the error.

err

An int32 value indicating whether the formatted text was written to the stream buffer successfully. This value will be the number of code units written to the stream unless an error occurs. If an error occurs then this value is a negative error code. See Error Codes for the different error codes and their values. Use the Compare to Error block rather than the error code itself to check for specific error codes. To check for errors in general use the Compare to Zero block to check whether err output is less than zero.

Data Type Support

For scalar quantities, the Print block accepts signals of any of the built-in Simulink data types at its data inputs. Fixed point is not currently supported.

For array quantities, as indicated by a dimension specifier in the format string, the Print block only accepts signals of the data type corresponding to the format specifier at that port.

Parameters and Dialog Box

Print

Format string

The format string used to format the data. Refer to the Format Strings for Printing page for a description of the format string. This parameter is treated as a string literal. It is not evaluated. Hence, do not enclose the format string in quotes unless you wish the quotes to appear in the output.

Maximum number of code units to print

This parameter restricts the total number of code units written to the stream. This limit is a hard limit. The total number of code units written to the stream will never exceed this limit, even if the output for an input port is truncated or all the input ports have not been included in the output.

Optimize for

Determines whether the block is optimized for maximizing throughput or minimizing latency. If this option is set to maximize throughput, then the block only flushes the stream buffer to the underlying communication channel when when the stream buffer is full. In this way, as much data as possible can be transferred in each packet for packet-based protocols such as TCP/IP. The transmission protocol is determined by the target URI used when opening the QUARC Console.

If this option is set to minimize latency then it flushes the stream buffer to the underlying communication channel each time the block executes. Doing so minimizes the time between when the data is generated and when it is sent to the remote host, but it may under-utilize the communications bandwidth since packets may not be full when they are sent.

Sample time

The sample time of the block. A sample time of 0 indicates that the block will be treated as a continuous time block. A positive sample time indicates that the block is a discrete time block with the given sample time.

A sample time of -1 indicates that the block inherits its sample time from the input. The block inherits the sample time by default.

To set the sample time to the fundamental sampling time of the model, use the qc_get_step_size function, which is a QUARC function that returns the fundamental sampling time of the model. The fundamental sampling time of the model is the sampling time entered in the Fixed step size field of the Solver pane of the Configuration parameters dialog.

Active during normal simulation

Indicates whether this block should execute during normal simulation. If this option is not checked then the block will not print to the MATLAB command window during normal simulation. This parameter has no effect on generated code.

Targets

Target Name

Compatible*

Model Referencing

Comments

QUARC Win32 Target

Yes

Yes

QUARC Win64 Target

Yes

Yes

QUARC Linux Nvidia Target

Yes

Yes

QUARC Linux QBot Platform Target

Yes

Yes

QUARC Linux QCar 2 Target

Yes

Yes

QUARC Linux QDrone 2 Target

Yes

Yes

QUARC Linux Raspberry Pi 3 Target

Yes

Yes

QUARC Linux Raspberry Pi 4 Target

Yes

Yes

QUARC Linux RT ARMv7 Target

Yes

Yes

QUARC Linux x64 Target

Yes

Yes

QUARC Linux DuoVero Target

Yes

Yes

QUARC Linux DuoVero 2016 Target

Yes

Yes

QUARC Linux Verdex Target

Yes

Yes

QUARC QNX x86 Target

Yes

Yes

Last fully supported in QUARC 2018.

Rapid Simulation (RSIM) Target

Yes

Yes

Output will be sent to stdout rather than the QUARC Console.

S-Function Target

No

N/A

Old technology. Use model referencing instead.

Normal simulation

Yes

Yes

If the Active during normal simulation option is checked then the Print block outputs to the MATLAB Command Window.

* Compatible means that the block can be compiled for the target.

See Also

 

navigation bar