Hi, I am using serial port communication. I can write and read the data but the warning after "fscanf" keep pop up. Below attached the code. Code:
s=serial('COM6','BaudRate',115200,'Parity','none'...
,'DataBits',8,'FlowControl','none'...
,'Terminator','LF/CR');
fopen(s);
fprintf(s,'t');
out = fscanf(s)
Warning: A timeout occurred before the Terminator was reached.
May i know what is the problem?

2 件のコメント

Abhirama B A
Abhirama B A 2019 年 7 月 16 日
I am also having the same problem even after using the code
set(s, 'TimeOut', 100)
can you help to get rid of this?
Walter Roberson
Walter Roberson 2019 年 7 月 16 日
Check the baud rate you are configuring.
Check that the terminator matches.
Use a program such as TeraTerm to verify that you are able to receive data from the port.

サインインしてコメントする。

 採用された回答

Jan
Jan 2012 年 6 月 22 日

1 投票

If the timeout occurred to early, what about increasing the time?
set(s, 'TimeOut', 100)
? But the default of 10 seconds should be long enough... Perhaps the other parameters are not correct?

5 件のコメント

Walter Roberson
Walter Roberson 2012 年 6 月 22 日
In particular double-check the terminator.
Shawn Chang
Shawn Chang 2012 年 6 月 25 日
Hi, thanks for replied. After i set the time out to 100,and check the terminator, the warning still exist. Does the warning will affect thereceiving data?
Walter Roberson
Walter Roberson 2012 年 6 月 25 日
The warning might be indicating that you are not getting any data at all.
If you are getting data then the timeout will be slowing down your program a lot.
Shawn Chang
Shawn Chang 2012 年 6 月 28 日
Thanks Jan and Walter replied, now I know how the stuff is worked.
wenshuo dong
wenshuo dong 2018 年 8 月 1 日
Can you tell me what is the problem? how can I figure it out? I meet the same issue as yours. Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2012 年 6 月 22 日

コメント済み:

2019 年 7 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by