warning in serial properties
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I created a code like this
and I have a problem that the serial function is not supported in matlab 2024, if I want to change to the matlab 2024 version how will the code be?
function [sphandle] = Dataserialport(comPortNum, bufferSize)
availablePorts = serialportlist;
if ~isempty(availablePorts)
disp('Serial port(s) already open. Re-initializing...');
end
comPortString = ['COM' num2str(comPortNum)];
sphandle = serial(comPortString,'BaudRate',921600);
set(sphandle,'Terminator', 'LF');
set(sphandle,'InputBufferSize', bufferSize);
set(sphandle,'Timeout',10);
set(sphandle,'ErrorFcn',@dispError);
fopen(sphandle);
end
function [sphandle] = Controlserialport(comPortNum,~)
comPortString = ['COM' num2str(comPortNum)];
sphandle = serial(comPortString,'BaudRate',115200);
set(sphandle,'Parity','none') ;
set(sphandle,'Terminator','LF');
fopen(sphandle);
end
1 comentario
Ayush Aniket
el 12 de Jun. de 2024
Hi Rangga,
Instead of serial function, you can try the serialport function. Refer to the documentation link: https://www.mathworks.com/help/matlab/ref/serialport.html
Respuestas (1)
Image Analyst
el 12 de Jun. de 2024
If you look in the help, it will tell you. Use serialport instead. I figure you can figure out how to change your code as well as, or better than, I can now that you know the new function to use.
help serial
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!