External Interfaces |
Event Types and Callback Properties
The serial port event types and callback properties are described below.
Event Type |
Associated Properties |
Break interrupt |
BreakInterruptFcn |
Bytes available | BytesAvailableFcn |
BytesAvailableFcnCount |
|
BytesAvailableFcnMode |
|
Error |
ErrorFcn |
Output empty |
OutputEmptyFcn |
Pin status |
PinStatusFcn |
Timer | TimerFcn |
TimerPeriod |
Break-Interrupt Event. A break-interrupt event is generated immediately after a break interrupt is generated by the serial port. The serial port generates a break interrupt when the received data has been in an inactive state longer than the transmission time for one character.
This event executes the callback function specified for the BreakInterruptFcn
property. It can be generated for both synchronous and asynchronous read and write operations.
Bytes-Available Event. A bytes-available event is generated immediately after a predetermined number of bytes are available in the input buffer or a terminator is read, as determined by the BytesAvailableFcnMode
property.
If BytesAvailableFcnMode
is byte
, the bytes-available event executes the callback function specified for the BytesAvailableFcn
property every time the number of bytes specified by BytesAvailableFcnCount
is stored in the input buffer. If BytesAvailableFcnMode
is terminator
, then the callback function executes every time the character specified by the Terminator
property is read.
This event can be generated only during an asynchronous read operation.
Error Event. An error event is generated immediately after an error occurs.
This event executes the callback function specified for the ErrorFcn
property. It can be generated only during an asynchronous read or write operation.
An error event is generated when a timeout occurs. A timeout occurs if a read or write operation does not successfully complete within the time specified by the Timeout
property. An error event is not generated for configuration errors such as setting an invalid property value.
Output-Empty Event. An output-empty event is generated immediately after the output buffer is empty.
This event executes the callback function specified for the OutputEmptyFcn
property. It can be generated only during an asynchronous write operation.
Pin Status Event. A pin status event is generated immediately after the state (pin value) changes for the CD, CTS, DSR, or RI pins. Refer to Serial Port Signals and Pin Assignments for a description of these pins.
This event executes the callback function specified for the PinStatusFcn
property. It can be generated for both synchronous and asynchronous read and write operations.
Timer Event. A timer event is generated when the time specified by the TimerPeriod
property passes. Time is measured relative to when the serial port object is connected to the device.
This event executes the callback function specified for the TimerFcn
property. Note that some timer events might not be processed if your system is significantly slowed or if the TimerPeriod
value is too small.
Events and Callbacks | Storing Event Information |
© 1994-2005 The MathWorks, Inc.