Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

instrcallback

Event information when event occurs

Syntax

instrcallback(obj,event)

Description

instrcallback(obj,event) displays a message that contains the event type, event, the time the event occurred, and the name of the serial port object, obj, 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.

Examples

The following example creates the serial port object, s, on a Windows® platform. It configures s to execute instrcallback when an output-empty event occurs. The event occurs after the *IDN? command is written to the instrument.

s = serial('COM1');
set(s,'OutputEmptyFcn',@instrcallback)
fopen(s)
fprintf(s,'*IDN?','async')
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

Tips

Use instrcallback as a template to create callback functions that suit your specific application needs.

Introduced before R2006a

Was this topic helpful?