Serial to SerialPort Object conversion
1 view (last 30 days)
Show older comments
Im porting my RS232 code from serial to the new serialport as suggested in 2019b.
I had previously used to check if any ports are open and if they are then close via:
if ~isempty(instrfind)
fclose(instrfind);
delete(instrfind);
delete(s) % s is my serial object (s=serial('Com1', etc...))
end
The documentation suggests not to use instrfind but serialportlist.
How would the above be achieved using this new command?
I also ran into an error using fopen & fclose with the new serialport object, but fortunately found this post from Walter!
The new serialport() interface does not use fopen() or fclose() . You just delete the object to close it.
I prefer the fopen() / fclose() interface myself... but then I used to write modem control programs where it was common to want to configure a port and open and close it while not deleting it.
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!