Transmit unformatted binary data
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.
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.
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.
Select this check box to display the current number of missed ticks as a block output.
Select this check box to grant other programs more CPU time while the kernel waits for a response from the hardware.
Enter the ID of the packet to receive. If your protocol does not have packet IDs, this parameter is disabled.
Check this check box if Packet identifier is an extended identifier.
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.
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.
From the list, select:
Default. Receive multibyte values in little-endian format.
Receive multibyte values in big-endian format.
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.
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.
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.
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.