フィルターのクリア

RS232 communication and clear buffer data

4 ビュー (過去 30 日間)
Prashant Funde
Prashant Funde 2016 年 5 月 23 日
コメント済み: Walter Roberson 2016 年 5 月 23 日
Hello everyone,
I wrote this code to communicate my device using MATLAB interface.
serConn = serial('COM11','BaudRate',9600); % Init. COM Port
fopen(serConn);
fprintf(serConn,' *ABCD*');
Rcvd = fread(serConn);
hexpass=sprintf('%02X ', Rcvd);
disp(hexpass);
fclose(serConn)
after compilation of this code i got following out....
24 12 32 45 00 90 09 08 .. .. .. ..
after running this code first time i got above mentioned output but if i run it 2nd time then it is showing me some garbage values like 1A 20 03 03 04 .. .. .. .. .. . But i want data will be same at both times. So please suggest how could i clear buffer values and how i will get same data all the time.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 5 月 23 日
fflush()
  2 件のコメント
Prashant Funde
Prashant Funde 2016 年 5 月 23 日
It gives me an error that its a undefined function 'fflush' for input arguments of type 'serial'.
Walter Roberson
Walter Roberson 2016 年 5 月 23 日
https://www.mathworks.com/matlabcentral/newsreader/view_thread/235066

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by