How to connect between two GUI via serial visual port ?

3 vues (au cours des 30 derniers jours)
dao
dao le 18 Nov 2014
Modifié(e) : dao le 19 Nov 2014
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 commentaire
Abdoo
Abdoo le 18 Nov 2014
i think need small modifications, can you attach two file (fig and m ).

Connectez-vous pour commenter.

Réponses (1)

Abdoo
Abdoo le 18 Nov 2014
i think need small modifications, can you attach two file (fig and m ).
  1 commentaire
dao
dao le 19 Nov 2014
thank, I will attach those now. Please help me.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by