cannot read from Serial Port object
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I am trying to communicate with a set of three flow meters (Omega FMA-1600A series) connected through a Serial-USB adapter. They are configured such that when the port receive 'A' (or 'B' or 'C'), the reading of the first (or the second, or the third) flow meter is sent back. This command line works well in the serial port program Terminal (https://sites.google.com/site/terminalbpp/)
In MatLab, I can create and connect to the serial port and get properties of the serial port, such as below: Serial Port Object : Serial-COM5
Communication Settings
Port: COM5
BaudRate: 19200
Terminator: 'LF'
Communication State
Status: closed
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0
However, when I sent letter 'A' using function fprintf(s,'A'), I receive no data back. See below:
s.BytesAvailable
ans =
0
I have read some of the answers to the problems in the community, and followed the steps to make sure that the device/port is on before turning on Matlab, and make sure that no other program is connected to the port. Still no success.
The system I am using R2012a, on Windows 7. Could anyone help with the issue? Thanks!!
Wendong
1 Kommentar
Matt Kindig
am 3 Mai 2013
I note that the 'Status' of the port is shown as 'closed'. Have you made sure to fopen() the port first? Such as:
s= serial('COM5', ....); %your serial settings here
fopen(s);
fprintf(s,'A');
s.BytesAvailable
Antworten (2)
Chago Rodriguez
am 15 Mai 2013
Wendog,
Have you resolved your issue ... I am super frustrated ... try everything ... an dit looks form MANY postings that this is a REAL flaw with MATLAB.
Like most everybody, I can communicate with between PC and device OK. I can write commands to the serial device (FMCW Radar), and commands are accepted. But I cannot READ anything and BytesAvailable also returns ZERO.
I have MATLAB R2012b, I took care of terminators, correctly setting DTR ..., to no avail. Let me know if you have a solution.
Chago
0 Kommentare
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!