fopen of serial object

37 ビュー (過去 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);
ser = fopen(s, 'w');
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 件のコメント
Walter Roberson
Walter Roberson 2021 年 10 月 8 日
The examples would have been for serial() rather than serialport()


その他の回答 (0 件)




Community Treasure Hunt

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

Start Hunting!

Translated by