How to connect between two GUI via serial visual port ?

조회 수: 1 (최근 30일)
dao
dao 2014년 11월 18일
편집: dao 2014년 11월 19일
I want send data between two GUI and I use Virtual serial port software to creat two serial port. I can send data to terminal software But it didn't appear in GUI 2 as I want ?
In GUI1, I set:
if true
a={'a' '123' '456' '789' ...'999' };
s=serial('COM1')
s.ReadAsyncMode = 'continuous';
s.Terminator = 'Lf'; % or 'LF' or 'CR'
s.BytesAvailableFcnMode = 'terminator';.
s.BytesAvailableFcn = @BytesAvailable_Callback;
s.OutputEmptyFcn = @OutputEmpty_Callback;
s.BreakInterruptFcn = @BreakInterrupt_Callback;
s.ErrorFcn = @Error_Callback;
s.PinStatusFcn = @PinStatus_Callback;
s.BreakInterruptFcn = @BreakInterrupt_Callback;
fopen(s) ;
set(s, 'FlowControl', 'software');
get(s) ;
for i=1:length(a)
fprintf(s,'%c',a{i})
end
end
In GUI2, I set:
if true
function connect_com_Callback(hObject, eventdata, handles)
global s ;
s = serial(get_string_callback(handles.select_com),'BaudRate',9600);
s.BytesAvailableFcnCount = 1;
set(s,'Timeout',60);
s.Terminator = 'LF';
s.BytesAvailableFcnMode = 'byte';
s.InputBufferSize = 1400000;
s.OutputBufferSize = 1400000 ;
% Declare some callback functions or interrupt functions
s.BytesAvailableFcn = @BytesAvailable_Callback;
fopen(s) ;
% set(s, 'FlowControl', 'software');
get(s) ;
set(handles.edit_status,'String','Connected') ;% connected to com
handles.com = s;
guidata(hObject, handles);
function BytesAvailable_Callback(obj,event)
global s myData;
myData = fgets(s)
end
Please, help me
  댓글 수: 1
Abdoo
Abdoo 2014년 11월 18일
i think need small modifications, can you attach two file (fig and m ).

댓글을 달려면 로그인하십시오.

답변 (1개)

Abdoo
Abdoo 2014년 11월 18일
i think need small modifications, can you attach two file (fig and m ).
  댓글 수: 1
dao
dao 2014년 11월 19일
thank, I will attach those now. Please help me.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by