How can I open and read data from a serial port?

3 ビュー (過去 30 日間)
Kalen Timbs
Kalen Timbs 2016 年 5 月 24 日
コメント済み: islam dib 2020 年 12 月 9 日
To open/read pre-recorded data I have previously used:
fileID = fopen('filename.txt', 'rt'); line = fgetl(fileID);
to read the text file line by line. However, I need to be able to read data from an instrument connected to a serial port.
i have used
fid = serial(COMx,baudrate,9600);
fopen(fid);
Will this work for a live instrument?

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 5 月 24 日
fid = serial('COMx', 'baudrate', 9600);
You should also consider setting the Terminiator property.
  1 件のコメント
islam dib
islam dib 2020 年 12 月 9 日
hello,
what u mean by "You should also consider setting the Terminiator property." ?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by