필터 지우기
필터 지우기

Serial to SerialPort Object conversion

조회 수: 1 (최근 30일)
Jason
Jason 2020년 1월 6일
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개)

카테고리

Help CenterFile Exchange에서 Serial and USB Communication에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by