2014-02-14 13 views
1

我有一个传感器连接到我的电脑,我下载了一些通过串口与MATLAB连接的代码。Matlab如何设置串行超时函数?

我有这样的代码,其初始化连接并设置一些参数:

sport = serial(com_port); % assigns the object sport to serial port 

set(sport, 'BaudRate', 9600); 
... other configs 
set(sport, 'Timeout', Timeout); 
set(sport, 'ReadAsyncMode', 'continuous'); 

凡超时是一个变量设置为5

set(sport, 'Timeout', Timeout);行实际上做了什么?我查看了MATLAB的串口设备文档-Found Here-,但我找不到有关设置串口超时的文档。

我最初的想法是,这个值是我的sport对象被用来收集数据的时间,但下一行set(sport, 'ReadAsyncMode', 'continuous');告诉设备不断流数据。

此外,我不想在不知道自己在做什么的情况下改变太多值,因为害怕破坏任何东西。请帮忙!

回答

0

请参阅TimeOut属性in the matlab documentation的说明。 TimeOut设定“等待时间来完成一读或写操作”

Contents左边菜单,您可以选择其他属性,如ReadAsyncMode和了解他们的财产。