How to connect between two GUI via serial visual port ?

3 visualizaciones (últimos 30 días)
dao
dao el 18 de Nov. de 2014
Editada: dao el 19 de Nov. de 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 comentario
Abdoo
Abdoo el 18 de Nov. de 2014
i think need small modifications, can you attach two file (fig and m ).

Iniciar sesión para comentar.

Respuestas (1)

Abdoo
Abdoo el 18 de Nov. de 2014
i think need small modifications, can you attach two file (fig and m ).

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by