Serial Port Close and Open

3 visualizaciones (últimos 30 días)
dmfwlansejr
dmfwlansejr el 22 de Jul. de 2021
I have design in GUIDE
First, I Write and Read. It's OK!
Second, I Write and Read
=> Write is OK! (The Board has LCD display), But Read data is First Write Data or all zero
=>However, Serial Port Close and Open then Second Write data is Read
EXAMPLE
WRITE 2, READ 2
WRTE 3 READ 2 or '0'
PORT CLOSE AND OPEN, THEN READ IS 3
WHERE IS THE PROBLEM?
% ------- Serial Port Open ----------------
function portopen_Callback(hObject, eventdata, handles)
global s
global portnum
s = serial(portnum, 'BaudRate', 115200, 'DataBits', 8, 'StopBits', 1, 'Parity', 'non');
set(s,'Terminator','');
fopen(s);
set(handles.text6,'String',' 115200bps, Data:8, Stop:1, No Parity'); % Overwrite
set(handles.text5,'String', [portnum ' Connect :']); % Overwrite
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in portclose.
function portclose_Callback(hObject, eventdata, handles)
global s
set(handles.text5,'String', ' Disconnect');
set(handles.text6,'String','');
fclose(s);

Respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by