Sending the <Esc> function through a serial port

조회 수: 2 (최근 30일)
Gunnar S. Hilmarsson
Gunnar S. Hilmarsson 2011년 7월 1일
Hi,
My name is Gunnar and I am a M.Sc. student of engineering. I am working on controlling a Fraction Collector through my serial port. It works fine, all except this one function called pulse. In the guide for the device it says this about this function: "Pulsing will continue until it is aborted with an esc character."
This works fine when I use hyperterminal (windows program) to communicate with the serial port, but how to send Esc through matlab.
I have tried sending '0x1B', 'ESC', 'AT s2', '###' and many more. All have been formatted as string.
Is there perhaps any way of having fprintf recognize that my string is ascii code ?
However I am open to any suggestions.
Thanks in advance.

채택된 답변

Walter Roberson
Walter Roberson 2011년 7월 2일
fwrite(s,char(27))
  댓글 수: 1
Gunnar S. Hilmarsson
Gunnar S. Hilmarsson 2011년 7월 5일
Awesome, works like a charm.
I had problems using fwrite to the serial port, but i just used fprintf with the char(27) function and it did the trick.
Thanks a bunch Walter :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by