Read binary data or a CAN message from a communication channel
Read unformatted binary data from a port or file. After you add a Packet Input block to your model, double-click the block to set its parameters.
The driver must be one of:
Standard Devices > Serial Port
Standard Devices > UDP Protocol
Standard Devices > File
Vector > CAN Device
When you install a UDP device, enter port addresses in decimal format in the Standard Devices UDP Protocol dialog box.
Output Data— Data received from communication channel
Data values that were received from the communication channel as unformatted binary data.
Timestamp— Packet timestamp port (optional)
This port shows the timestamp for the CAN message packets.
When you select Show packet timestamp port, this port is visible.
Input packet size— Number of bytes that each input packet contains
32(default) | integer
Enter the number of bytes expected in each input packet. This number must match the number of bytes required by the type specifications in Block output data types.
Block output data types— Output type and grouping of data from the packet
'4*double'(default) | character vector | cell array of character vector
One or more character vectors that specify how the data in each packet is to be typed and grouped for input to the application. The Packet Input block has an output port corresponding to each character vector in Block output data types. Changing the number of character vectors changes the number of output ports.
Each character vector has the format [
The data that the character vector describes has the type specified
datatype and the width specified by
n is not specified, the width is
'double' means one
'4*int8' means a vector of four
You can also type
'CAN_MESSAGE' to specify a single
By providing a cell array of such character vectors, you can
convert an input packet into the types required, packaged into vectors.
For example, specifying
three ports. The first and second each output an
and the third outputs a
two ports: a vector of two
int16 values, and a
The block forces an out-of-range value to the maximum value for that data type.
Input packet field byte order— Byte order of packet acquired from device
Little Endian(default) |
From the list, select:
Little Endian (default)
— Send multibyte values in little-endian format.
Big Endian — Send
multibyte values in big-endian format.
Show packet timestamp port— Add port
Timestampthat outputs CAN message timestamps
When you select this check box, the block makes visible the
Timestamp. This port shows the timestamps
for the CAN message packets. If your protocol does not have packet
timestamps, the block ignores this value.