MATLAB 帮助中心
清空串行端口设备缓冲区
flush(device)
flush(device,"input")
flush(device,"output")
flush(device) 刷新指定的串行端口的输入和输出缓冲区中的所有数据。
device
示例
flush(device,"input") 仅清空输入缓冲区。
flush(device,"output") 仅清空输出缓冲区。
全部折叠
创建到串行端口设备的连接。
device = serialport("COM3",9600)
device = Serialport with properties: Port: "COM3" BaudRate: 9600 NumBytesAvailable: 0 Show all properties, functions
向设备写入一些数据,并查看输入缓冲区中可供读取的字节数。
write(device,1:5,"uint8") device.NumBytesAvailable
ans = 5
清空输入和输出缓冲区。
flush(device);
查看可供读取的字节数。
device.NumBytesAvailable
ans = 0
输入缓冲区中没有数据。
serialport
串行端口连接,指定为 serialport 对象。
示例: flush(device) 清空串行端口连接 device 中的数据。
在 R2019b 中推出
write
read
getpinstatus
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处