フィルターのクリア

Device communication

2 ビュー (過去 30 日間)
Slobodan Djordjevi?
Slobodan Djordjevi? 2011 年 12 月 7 日
Hi
I need help with reading data from a device. My code :
s1 = serial('COM4');
s1.BaudRate = 9600;
s1.DataBits = 8;
s1.Parity = 'none';
s1.StopBits = 1;
s1.FlowControl = 'none';
s1.Terminator ='CR';
fopen(s1);
fread(s1);
fclose(s1);
delete(s1);
The problem occurs, because I have to send/transmit a macro to the device. Macro is ACK(acknowledgment/006) in ASCII. I don't know how to do this. What should I add to my code?
Thanks a bunch in advance!

採用された回答

Walter Roberson
Walter Roberson 2011 年 12 月 7 日
fwrite(s1, char(6))

その他の回答 (2 件)

Slobodan Djordjevi?
Slobodan Djordjevi? 2011 年 12 月 7 日
It worked, thanks!
Now the the data is an array of 1x17 of some numbers 48 48 48 48 46 48 52 13 48 48 48 48 46 48 48 13 10, am I supposed to convert this?
  1 件のコメント
Walter Roberson
Walter Roberson 2011 年 12 月 7 日
fwrite(s1, char([48 48 48 48 46 48 52 13 48 48 48 48 46 48 48 13 10]))
Please double-check the list of characters. At the very end you have 10 following the 13, which is linefeed following carriage return, but earlier in the sequence you have a carriage return by itself. Very few systems mix carriage return alone with carriage return followed by linefeed.

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


Slobodan Djordjevi?
Slobodan Djordjevi? 2011 年 12 月 7 日
Nevermind, I did it with char(data).
Thank you Walter!

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by