External Interfaces/API    

Using Events and Actions

You can enhance the power and flexibility of your serial port application by using events. An event occurs after a condition is met and may result in one or more actions.

While the serial port object is connected to the device, you can use events to display a message, display data, analyze data, or perform just about any other action. Actions are controlled through action properties and action functions. All event types have an associated action property. Action functions are M-file functions that you construct to suit your specific application needs.

You execute an action when a particular event occurs by specifying the name of the M-file action function as the value for the associated action property.

Example: Introduction to Events and Actions

This example uses the M-file action function instraction to display a message to the command line when a bytes-available event occurs. The event is generated when the terminator is read.

The resulting display from instraction is shown below.

End the serial port session.

You can use the type command to display instraction at the command line.


 Example: Reading Binary Data Event Types and Action Properties