Main Content

Serialdev

连接到串行设备上的Beaglebone黑色硬件

描述

此对象表示来自MATLAB的连接®software to a serial device on the BeagleBone®黑色硬件。要创建此对象,请使用Serialdevfunction. To exchange data with the serial device, use this object with the functions listed in对象功能

创建

描述

例子

serial= SerialDev(BBB,,,,港口创建从MATLAB软件到Beaglebone黑色硬件上的串行设备的连接。

例子

serial= SerialDev(BBB,,,,港口,,,,baudRate,,,,数据库,,,,平价,,,,停止creates a connection from the MATLAB software to the serial device on the BeagleBone Black hardware using optional arguments to override the default values for baud, data bits, parity, and stop bits.

输入参数

展开全部

Beaglebone黑色连接使用Beaglebone,指定为一个对象。

连接到Beaglebone黑色硬件的串行端口的名称,该端口指定为字符向量。

例子:'/dev/ttyo1'

数据类型:char

特性

展开全部

This property is read-only.

The rate at which the data is transferred over the serial line, specified as a scalar. The baud is measured in seconds. This property is set by thebaudRate输入参数。如果未指定为输入参数,则为默认值。在对象创建后不能更改它。

例子:9600

数据类型:双倍的

This property is read-only.

每个字符的位数,指定为标量。此属性由数据库输入参数。如果未指定为输入参数,则为默认值。在对象创建后不能更改它。

例子:8

数据类型:双倍的

This property is read-only.

均衡位的类型要添加到数据中,称为字符向量。

A parity bit is used to detect error in data transmission.

  • '没有任何'- 在数据传输中不使用奇偶校验来检测错误。

  • '奇怪的'- 数据位加上奇偶校验位产生的奇数为1s。

  • '甚至'- 数据位加上奇偶校验位会产生偶数1s。

  • 'mark'- 平价位总是1。

  • '空间'- 平价位总是0。

此属性由平价输入参数。如果未指定为输入参数,则为默认值。在对象创建后不能更改它。

例子:'没有任何'

数据类型:char

This property is read-only.

数据传输中用作停止位的位数。停止位标志着传输单元的末端。此属性由停止输入参数。如果未指定为输入参数,则为默认值。在对象创建后不能更改它。

例子:1

数据类型:双倍的

在几秒钟内完成对象创建的等待时间,该对象创建指定为double类型的正值。

例子:10

数据类型:双倍的

对象功能

read 从串行设备读取数据
将数据写入串行设备

例子

全部收缩

You can connect to a serial device from the MATLAB software, write data to the device, and read data from the device.

Create a connection from the MATLAB software to the BeagleBone Black hardware.

bbb = beaglebone

启用串行端口1

enableSerialPort(bbb,1) bbb.AvailableSerialPorts
ans ='/dev/ttyo1'

'/dev/ttyo1', 这'o'is the capital lettero数量,而不是零。

显示端口的位置1TX和RX引脚,P9_24 (UART1_TXD)andP9_26(UART1_RXD),,,,on the GPIO header.

showPins(bbb)

Beaglebone黑板使用+3.3V. Do not connect BeagleBone Black hardware directly to devices that use higher voltages.

将Beaglebone黑色串行端口连接到一个+3.3v串行设备。

  • To receive data, connect theP9_26(UART1_RXD)pin on the BeagleBone Black hardware to the TxD pin on the serial device.

  • 要传输数据,请连接P9_24 (UART1_TXD)将Beaglebone黑色硬件固定在串行设备上的RXD引脚上。

  • 为了提供力量,请连接一个+3.3 vBeaglebone黑色硬件上的别针VCC销钉在串行设备上。

  • 要接地串行设备,请连接接地销(gnd)on the BeagleBone Black hardware to thegnd销钉在串行设备上。

研究串行设备需要BAUD,数据位,奇偶校验和停止位所需的值。

创建连接,serial,从MATLAB软件到串行设备。

serial = serialdev(bbb,'/dev/ttyo1',9600)
serial = Serialdev with Properties: BaudRate: 9600 DataBits: 8 Parity: 'none' StopBits: 1 Timeout: 10

将一对值写入需要特定数据类型的串行设备。

写(serial,[10 12],'uint16'

从串行端口中读取100个元素的数字数组。

输出=读取(序列,100,'uint16'

增加串行端口的超时周期。

serial.timeout = 20
序列=属性的SerialDev:Baudrate:115200数据库:8奇偶校验:'none''stopbits:1超时:20

版本历史记录

在troduced in R2015a