xPC Target | ![]() ![]() |
The RS232 Binary Receive Block was designed with generality in mind. To this end, it supports reception of variable length packets. A packet can be split up between two different RS232 Binary Receive blocks, say for a fixed length header followed by a variable length body. However, the maximum possible length of a packet has to be specified in the block, and the output from the block is a vector whose width is equal to this maximum length.
If you drop a block into your model and double-click it, a Block Parameters dialog box opens where you can modify the parameters for this block.
Block Parameters
COM Port -- From the list, select, COM1
, COM2
, COM3
, or COM4
. This is the RS232 port you want to receive data from. An RS232 Setup block must also exist for the same COM port in your model.
Maximum width per packet -- Enter a value that Simulink and Real-Time Workshop use to allocate memory for the received data. This is also the width of the data output. In case the actual data is less wide than the maximum, the first few bytes of the output vector are the real data and the remaining bytes are undefined.
Sample time -- Specifies how often the block has to be executed. In the example dialog box shown above, the setting of -1 specifies an inherited sample time, either from the base sample time of the model, or from the block that the output of this block goes to.
Block Inputs
The RS232 Binary Receive Block has two input ports.
Block Outputs
The RS232 Binary Receive block has two output ports:
uint8
s, and is a vector of width equal to that specified in the Maximum width per packet parameter. If the Length input is less than this width, the first number of bytes equal to Length are the real data and the rest is garbage.
![]() | Using RS232 Binary Mode | RS232 Binary Send Block | ![]() |