RS232 Serial communication
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 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 commentaires
Voir également
Catégories
En savoir plus sur Data Acquisition Toolbox Supported Hardware dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!