Effacer les filtres
Effacer les filtres

Serial Port Close and Open

3 vues (au cours des 30 derniers jours)
dmfwlansejr
dmfwlansejr le 22 Juil 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);

Réponses (0)

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