MATLAB Function Reference | ![]() ![]() |
Display event information when an event occurs
Syntax
instraction(obj, event)
Arguments
obj |
An serial port object. |
event |
The event that caused the action to execute. |
Description
instraction(obj, event)
displays a message that contains the event type, the time the event occurred, and the name of the serial port object that caused the event to occur.
For error events, the error message is also displayed. For pin status events, the pin that changed value and its value are also displayed.
Remarks
You should use instraction
as a template from which you create action functions that suit your specific application needs.
Example
The following example creates the serial port objects s
, and configures s
to execute instraction
when an output-empty event occurs. The event occurs after the *IDN?
command is written to the instrument.
s = serial('COM1'); set(s,'OutputEmptyAction','instraction') fopen(s) fprintf(s,'*IDN?','async')
The resulting display from instraction
is shown below.
OutputEmpty event occurred at 08:37:49 for the object: Serial-COM1.
Read the identification information from the input buffer and end the serial port session.
idn = fscanf(s); fclose(s) delete(s) clear s
![]() | inspect | instrfind | ![]() |