Read data via serial port

조회 수: 1 (최근 30일)
Pavel Filjac
Pavel Filjac 2020년 2월 26일
답변: Charan Jadigam 2020년 3월 4일
Hello, I would like to read for example these datas: "05 04 A9" but when I try it with function read, it returns only datas until the first space. Could you advice me, how can I read whole datas also with spaces?
app.s = serialport(app.a,115200,"DataBits",8, "Timeout",1);
received = read(app.s,59,"string");

답변 (1개)

Charan Jadigam
Charan Jadigam 2020년 3월 4일
Hi,
To read string from a serial port, you need to configure termination character first and then read. Use the following functions.
configureTerminator(s,"LF");
data = readline(s);
You can read more about the function configureTerminator

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by