I am trying to communicate with a device via RS232. When communicating thru Windows Powershell, I wrote the following and I can receive data just fine.
C:\> $port= new-Object System.IO.Ports.SerialPort COM67,4800,Even,7,one
C:\> $port.open()
C:\> $port.ReadLine()
I get the expected data in Powershell just fine when I do this. The remote device is currently set RUN mode, where it output data constantly without polling. Now, when I try to communicate with the same device thru MATLAB, I am facing issues. This is what I have written in the *.m file:
s = serial('COM67');
set(s,'BaudRate',4800, 'DataBits', 7, 'Parity', 'even', 'StopBits', 1);
fopen(s);
out = fscanf(s);
fclose(s)
delete(s)
clear s
I do not get an output, and get a timeout message. What am I doing wrong? Thank you.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 9월 22일

0 개 추천

It could be a line termination property issue. For example it might sending carriage returns but the default setting is newlines

카테고리

도움말 센터File Exchange에서 Data Acquisition Toolbox Supported Hardware에 대해 자세히 알아보기

질문:

2017년 9월 22일

답변:

2017년 9월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by