主要内容

Serial Send

通过串行端口发送二进制数据

  • 库:
  • 仪器控制工具箱

    Motor Control Blockset / Protection and Diagnostics

  • 串行发送块

Description

Serial Sendblock configures and opens an interface to the specified serial port. The configuration and initialization occur once at the start of the model's execution. The block sends data from the model to the serial port during the model's run time. You can use multipleSerial Sendblocks at a time to send data to a specific serial port.

Note

You must configure your serial port parameters using theSerial Configurationblock before you specify theSerial Sendblock parameters.

Serial Send块具有一个接受1-D向量和矩阵数据的输入端口。该块没有输出端口。该块从输入端口的信号继承数据类型。有效的数据类型是single,double,int8,uint8,INT16,uin16,int32, 和uint32.

Other Supported Features

  • Serial Sendblock supports the use of Simulink®加速器模式,但不是快速加速器。此功能加快了Simulink模型的执行加快。金宝app

  • Serial Sendblock supports the use of model referencing. This feature lets your model include other Simulink models as modular components.

  • Serial Send块支持C/C金宝app ++代码生成。此功能允许您使用C ++代码生成C ++代码金宝appSimulink Coder™.

For more information on these features, see the金宝app文档。

Ports

输入

expand all

数据values to send from the block over your serial port, specified as a vector, matrix, or array. Set the parameters for this block before you send data.

数据Types:single|double|int8|INT16|int32|uint8|uint16|uint32

Parameters

expand all

您要将数据发送到的计算机上的串行端口。从可用端口选择一个端口,然后使用该端口配置端口Serial Configurationblock. If you have not configured a port, the block returns an error when you run your model.

Note

每一个Serial Sendblock must have a configuredSerial Configurationblock. If you use multiple serial ports in your simulation, you must configure each port using a separateSerial Configurationblock.

Programmatic Use

Block Parameter:Port
Type:character vector, string

指示数据块开始的标题。这Serial Send在将数据发送到串行端口之前,块将标题添加到数据的前面。默认情况下,未指定任何标头。

这numeric array specified in this parameter is theuint8integer representation of the corresponding ASCII characters. The exact form of this parameter depends on the type of the ASCII character.

Type of ASCII Character 示例ASCII字符 MATLAB Command Parameter Value
Special character “#” uint8('#') [35]
Numeric "81" uint8('81') [56 49]
Alphabet “开始” uint8('Start') [83 116 97 114 116]

You can also specify this parameter using the hexadecimal representation of the ASCII characters.

Programmatic Use

Block Parameter:Header
Type:character vector, string
Values:integer array

Terminator that indicates the end of your data block. TheSerial Sendblock appends the terminator to the data before sending it over the serial port.

If you selectCustom Terminator, you can specify your own terminator value.

Programmatic Use

Block Parameter:Terminator
Type:character vector, string
Values:''|'CR ('\r')'|'LF ('\n')'|'cr/lf('\ r \ n')'|'null('\ 0')'|'Custom Terminator'
Default:''

Custom terminator that indicates the end of your data block. TheSerial Sendblock appends the terminator to the data before sending it over the serial port.

这numeric array specified in this parameter is theuint8integer representation of the corresponding ASCII characters. The exact form of this parameter depends on the type of the ASCII character.

Type of ASCII Character 示例ASCII字符 MATLAB Command Parameter Value
Special character “#” uint8('#') [35]
Numeric "81" uint8('81') [56 49]
Alphabet “结尾” uint8('End') [69 110 100]

You can also specify this parameter using the hexadecimal representation of the ASCII characters.

Programmatic Use

Block Parameter:CustomTerminator
Type:character vector, string
Values:integer array

This parameter has the simulation wait while the block sends data. Unselect the check box if you do not want the write operation to cause the simulation to wait.

如果启用阻止模式,则模拟会等待发送数据。如果您不启用阻止模式,则模拟将连续运行。

Programmatic Use

Block Parameter:EnableBlockingMode
Type:character vector, string
Values:'on'|'off'
Default:'on'

Extended Capabilities

他的版本tory

Introduced in R2008a