该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
请问一下为什么用串口来连接两台计算机,做发送与接收,可是却没反应呢?
帮我看下程序,行么?
发送端的
clear;
s=serial('com2','baudrate',1200);
set(s, 'Parity', 'none') ; % Set parity as none
set(s, 'Databits', 8) ; % set the number of data bits
set(s, 'StopBits', 1) ; % set number of stop bits as 1
set(s, 'InputBufferSize', 512) ;
set(s, 'Timeout', 5) ;
s.Terminator='LF';
s.FlowControl='none';
set(s, 'OutputBufferSize', 512) ;
fopen(s);
get(s,'status');
fprintf(s,'abc\n','async');
stopasync(s);
fclose(s);
delete(s);
clear s;
接收端的
s=serial('com2','baudrate',1200);
set(s, 'Parity', 'none') ; % Set parity as none
set(s, 'Databits', 8) ; % set the number of data bits
set(s, 'StopBits', 1) ; % set number of stop bits as 1
set(s, 'InputBufferSize', 512) ;
set(s, 'Timeout', 5) ;
s.Terminator='LF';
s.FlowControl='none';
set(s,'readasync','continuous');
s.Terminator='LF';
fopen(s);
get(s,'status');
a=fscanf(s);
fclose(s);
delete(s);
clear s;
谁懂,帮帮忙啊~~