%% Configure Device Callback and Trigger
% Configure serial port, Bluetooth, or TCP/IP interface callback and then clear callbacks.
% Create a connection to a serial port device using serialport. You can also connect to a Bluetooth device using bluetooth or a TCP/IP client using tcpclient.

dev = serialport("COM3",9600);

% Set the callback to trigger when 50 bytes of data are available to be read.

configureCallback(dev,"byte",50,@callbackFcn)

% Set the callback to trigger when a terminator is available to be read.

configureCallback(dev,"terminator",@callbackFcn)

% Turn the callback off.

configureCallback(dev,"off")

% Copyright 2020 The MathWorks, Inc.