Trying GUI with serial ports
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I'm trying to make a graphical user interface for serial communication between two of my USB ports. There are 2 edit boxes, one is for the tranciever the other is for the received data. There is a pushbutton also, when it's hit, the data must be sent from port A to port B. I tried this code:
function gomb_Callback(hObject, eventdata, handles)
s1 = get(handles.ado1, 'String'); %ado1 is the tranciever
fprintf(input, s1);
r1 = fscanf(output);
set(handles.vevo, 'String', r1); %vevo is the receiver
The instruments are connected and opened in the command window and it's working there, but in the GUI I get the following errors:
Error in ==> SerialCom>gomb_Callback at 174
fprintf(input, s1);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> SerialCom at 43
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)SerialCom('gomb_Callback',hObject,eventdata,guidata(hObject))
Please help me. Thanks.
0 comentarios
Respuestas (1)
Walter Roberson
el 30 de Sept. de 2015
"input" is not defined in that routine.
2 comentarios
Walter Roberson
el 30 de Sept. de 2015
You created those variables in the base workspace if you did that at the command line. Later when you find the appropriate place to put the code, the variables would be created in the workspace of some function. Either way you need to make the values available from the workspace they were defined in, to the place they need to be used. The link I included above discusses several ways that can be done.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!