How to connect between two GUI via serial visual port ?

3 ビュー (過去 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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by