필터 지우기
필터 지우기

serial com RS422, sending hexadeximal coomands

조회 수: 4 (최근 30일)
fima v
fima v 2017년 11월 27일
편집: Walter Roberson 2017년 11월 28일
Hello,i am trying to communicate with a "reciever" device which is connected as shown in the attached photo(serial-com).
i communicated with the device using PCOM software,as shown in the attached photo with "hexadeximal" commands.
i tried to do the same thing with matlab shown as following,
but it doesnt do anything,how to do these hexadecimal commands in matlab?
Thanks
s = serial('COM4');
set(s,'BaudRate',115200);
fopen(s);
fprintf(s,'0801')
fprintf(s,'63')
out = fscanf(s);
fclose(s)
delete(s)
clear s

채택된 답변

Greg
Greg 2017년 11월 28일
편집: Greg 2017년 11월 28일
'63' and '0801' in MATLAB are character arrays. The binary of '63' is not the same as the binary of 0x63. Try:
fwrite(s,uint8(hex2dec('0801')));
fwrite(s,uint8(hex2dec('63')));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by