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
2016-9-8
Supposing s is the serial port object, then
set(s, 'BytesAvailableFcn', @(src, event) assignin('base','DATA', fscanf(src, '%s') )
for example.
类别
在 帮助中心 和 File Exchange 中查找有关 Serial and USB Communication 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!