RS232 Serial communication
8 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2017 年 9 月 22 日
It could be a line termination property issue. For example it might sending carriage returns but the default setting is newlines
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Acquisition Toolbox Supported Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!