i can not read data from serial

the program is design as follow:
g=serial('com5')
set(g,'baudrate',38400)
g.inputbuffersize=131072
g.outbuffersize=5120
g.outputbuffersize=5120
g.timeout=30
g.readasyncmode='continuous'
g.bytesavailablefcnmode='byte'
g.bytesavailablefcncount=48
g.terminator='cr'
fopen(g)
fread(g,4,'uint16')
com5 is ready,but
Warning: The specified amount of data was not returned within the Timeout period.
I cannot read the data ,please help me
the parameter of g is:
g
Serial Port Object : Serial-COM5
Communication Settings
Port: COM5
BaudRate: 38400
Terminator: 'LF'
Communication State
Status: open
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 1

댓글 수: 2

Raju Purohit
Raju Purohit 2012년 11월 4일
Most possibly because there isn't any data being received.
Chago Rodriguez
Chago Rodriguez 2013년 5월 15일
MuDondong,
How did you resolved your issue. I have the same problem.
Thanks!
Chago

댓글을 달려면 로그인하십시오.

답변 (1개)

Mu dongdon
Mu dongdon 2012년 11월 4일

0 개 추천

when com5 is connected correctly, I use others soft to read data successfully, but I cannot use matlab read it,how can i do?
The data consists of four bytes, a byte is used as data start, expressed with 'FF', the other three is data, they are all hexadecimal

카테고리

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

태그

질문:

2012년 11월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by