User`s manual
8 Serial Port I/O
8-52
The AbsTime Field. AbsTime is defined for all events, and indicates the absolute
time the event occurred. The absolute time is returned using the
clock format.
day-month-year hour:minute:second
The Pin Field. Pin is used by the pin status event to indicate if the CD, CTS, DSR,
or RI pins changed state. Refer to “Serial Port Signals and Pin Assignments”
on page 8-6 for a description of these pins.
The PinValue Field. PinValue is used by the pin status event to indicate the state
of the CD, CTS, DSR, or RI pins. Possible values are
on or off.
The Message Field. Message is used by the error event to store the descriptive
message that is generated when an error occurs.
Creating and Executing Callback Functions
You can specify the callback function to be executed when a specific event type
occurs by including the name of the M-file as the value for the associated
callback property. You can specify the callback function as a function handle or
as a string cell array element. Function handles are described in the
function_handle reference pages.
For example, to execute the callback function
mycallback every time the
terminator is read from your device
s.BytesAvailableFcnMode = 'terminator';
s.BytesAvailableFcn = @mycallback;
Alternatively, you can specify the callback function as a cell array.
s.BytesAvailableFcn = {'mycallback'};
M-file callback functions require at least two input arguments. The first
argument is the serial port object. The second argument is a variable that
captures the event information given in Table 8-10, Event Information, on page
8-51. This event information pertains only to the event that caused the callback
function to execute. The function header for
mycallback is shown below.
function mycallback(obj,event)