RS232 Serial communication
12 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Walter Roberson
on 22 Sep 2017
It could be a line termination property issue. For example it might sending carriage returns but the default setting is newlines
0 Comments
See Also
Categories
Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!