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

2 visualizzazioni (ultimi 30 giorni)
Kalen Timbs
Kalen Timbs il 24 Mag 2016
Commentato: islam dib il 9 Dic 2020
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?

Risposte (1)

Walter Roberson
Walter Roberson il 24 Mag 2016
fid = serial('COMx', 'baudrate', 9600);
You should also consider setting the Terminiator property.

Community Treasure Hunt

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

Start Hunting!

Translated by