how to use bytesavailablefcn ?

hi
I definned bytesavailablefcn property from inspector like blow:
so whenever i need the "DATA" variable, it is update to last string from serialport. it works well.
but how i can define bytesavailablefcn from command line???
exceuse my english.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 9 月 8 日

0 投票

Supposing s is the serial port object, then
set(s, 'BytesAvailableFcn', @(src, event) assignin('base','DATA', fscanf(src, '%s') )
for example.

質問済み:

2016 年 9 月 8 日

回答済み:

2016 年 9 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by