필터 지우기
필터 지우기

fopen of serial object

조회 수: 14 (최근 30일)
Leon Ellis
Leon Ellis 2021년 10월 8일
댓글: Walter Roberson 2021년 10월 8일
Good day, I'm trying to open my serialport to connect and write data to my arduino uno mcu. However I keep getting an error. My code is:
s = serialport("COM1",9600);
configureTerminator(s,"CR/LF");
pause(1);
ser = fopen(s, 'w');
pause(1);
writeline(s,1);
My error is:
Error using fopen
First input must be a file name or a file identifier.
Help would be much appreciated.

채택된 답변

Walter Roberson
Walter Roberson 2021년 10월 8일
serialport() objects open themselves. There is no way to open or close them.
This does mean that if need to change the parameters of an object that you have to destroy it and recreate it.
I prefer the ability to explicitly close and open serial ports... but then I used to do dial-up work, where closing and opening objects was part of the normal flow of operations.
  댓글 수: 2
Leon Ellis
Leon Ellis 2021년 10월 8일
Thank you very much, all examples I was able to find contained the fopen() function so i thought it was necessary.
Walter Roberson
Walter Roberson 2021년 10월 8일
The examples would have been for serial() rather than serialport()

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by