warning in serial properties
Show older comments
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 Comment
Ayush Aniket
on 12 Jun 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
Answers (1)
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
Categories
Find more on Serial and USB Communication in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!