Why doesn't it work?

조회 수: 2 (최근 30일)
Bence Salanki
Bence Salanki 2015년 9월 28일
댓글: Bence Salanki 2015년 9월 29일
Hi,
I'm trying to create a serial communication between two of my USB ports with two USB-serial adapter and a cross-over cable. I'm using the following code:
input = serial('COM3');
output = serial('COM4');
fwrite(input, 'hello');
fgets(output);
After fgets() this is what I get:
Warning: A timeout occurred before the Terminator was reached.
It seems like there is no stop bit after the characters and I don't know what to do with it. Please help me.
Thanks.

답변 (1개)

Walter Roberson
Walter Roberson 2015년 9월 29일
fwrite(input, sprintf('%s\n', 'hello'));
or
fprintf(input, '%s\n', 'hello');
or
fprintf(input, 'hello'); %special case, adds \n automatically
  댓글 수: 1
Bence Salanki
Bence Salanki 2015년 9월 29일
Thank you!

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

카테고리

Help CenterFile Exchange에서 Thermal Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by