scom=serial('COM3');
set(scom,'BaudRate',9600,'FlowControl','none','Timeout',0.1);
scom.InputBufferSize=1024;%输入缓冲区为256B,缺省值为512B
scom.OutputBufferSize=1024;%输出缓冲区为256B,缺省值为512B
scom.Timeout=0.5;%Y设置一次读或写操作的最大完成时间为0.5s,缺省值为10s
%s.ReadAsyncMode='continuous';%(缺省方式);%在异步通信模式方式下,读取串口数据采用连续接收数据(continuous
%)的缺省方式,那么下位机返回的数据会自动地存入输入缓冲区中.
fopen(scom);
A=fscanf(scom);%d’,[10,100]读串口
fprintf(scom);%s’,’RS232’,’async’
fclose(scom);%关闭串口设备对象
delete(scom);%删除内存中的串口设备对象
clear scom; %清除工作空间中的串口设
这是我们的串口函数,但是编译时出现错误
编译提示为Warning: A timeout occurred before the Terminator was reached.
??? Error using ==> serial.fprintf at 73
CMD must be specified.
Error in ==> chuankou2 at 11
fprintf(scom);%s’,’RS232’,’async’
不知道原因 做课题急用
哪位好心人帮帮忙 万分感谢