Packet Output

Transmit unformatted binary data

Library

Real-Time Windows Target™

Description

The Packet Output block sends unformatted binary data. After you add a Packet Output block to your model, double-click the block to set its parameters.

The driver must be Standard Devices > Serial Port, Standard Devices > UDP Protocol, Standard Devices > File, or Vector > CAN Device. When you install a UDP device, enter port addresses in decimal format in the Standard Devices UDP Protocol dialog box.

Any serial output port can send data with sample rates up to 500 Hz. To enable a faster sample rate of up to 10 kHz for some output serial ports, see the following. The software does not support this option with all types of serial output hardware.

To enable a faster rate, click Install new board, select Standard Devices > Serial Port, and select Direct port access.

Parameters

Sample time

Enter a value representing how frequently you want the block to execute and interact with the I/O hardware. The block also synchronizes your model with the real-time clock at this sample rate.

    Tip   If you are using a fixed-step solver, you must enter the same value that you entered in the Fixed step size box in the Configuration Parameters dialog box, or an integer multiple of that value.

Maximum missed ticks

Enter the number of timer ticks that your model can lag behind the real-time kernel. When the model lags by more than this number, the block reports an error and simulation stops. Otherwise, simulation continues even if some ticks are missed.

Show "Missed Ticks" port

Select this check box to display the current number of missed ticks as a block output.

Yield CPU when waiting

Select this check box to grant other programs more CPU time while the kernel waits for a response from the hardware.

Packet identifier

Enter the ID of the packet to receive. If your protocol does not have packet IDs, this parameter is disabled.

Extended identifier

Check this check box if Packet identifier is an extended identifier.

Output packet size

Enter the number of bytes to be transmitted in the output packet. This number must be the same as the number of bytes required by the type specifications in Output packet field data types.

Output packet field data types

Enter a string, or a cell array of strings, that specifies how data provided by the application will be formatted into a packet for output to the device. The Packet Output block has an input port corresponding to each string in Output packet field data types. Changing the number of strings automatically changes the number of ports.

Each string has the format [n*]datatype. The data described by the string has the type specified by datatype and the width specified by n; or 1 if n is not specified. For example, 'double' means one double value, and '4*int8' means a vector of four int8 values. You can also type 'CAN_MESSAGE' to specify a single CAN_MESSAGE value.

The signal input to each port of the Packet Output block can be a scalar or vector of the desired data type. The string for each port specifies the type to be used when its signal is output to the device. If the format string for a port matches the type of the signal input to that port, the signal value appears verbatim in the output packet.

You can also perform type conversion on output. For example, if an input signal is a four-element int16 vector, but the corresponding string is '4*int8', each of the four integers is converted to an int8 before being written to the packet. The resulting data occupies four bytes in the output packet.

    Note:   An out-of-range value is forced to the maximum value for that data type.

Output packet field byte order

From the list, select:

  • Little Endian

    Default. Receive multibyte values in little-endian format.

  • Big Endian

    Receive multibyte values in big-endian format.

Show "Data Ready" port

Select this check box to indicate that the block has an output port that signals 1 if the block is ready to accept new data, and 0 otherwise.

Show "Data Error" port

Select this check box to indicate that the block has an output port that signals 1 if a data error has occurred, and 0 otherwise.

Initial value

Optional. Enter a vector that has the same number of elements as the sum of the widths of the input signals across all ports. The specified data is sent when simulation begins, before other data that is output during simulation.

Final value

Optional. Enter a vector that has the same number of elements as the sum of the widths of the input signals across all ports. The specified data is sent when simulation ends, after other data that is output during simulation.

Was this topic helpful?