From: Igor on
I've recently tried to communicate with my COM device, and ran into difficulties with asynchronous write, my OutputEmptyFcn callback isn't working...
Then I tried to create following test.m :
-----------------------------------------------------------------
s = serial('COM5')

fopen(s)

s.BytesAvailableFcnMode = 'terminator';
s.BytesAvailableFcn = @instrcallback;
s.OutputEmptyFcn = @instrcallback;
fprintf(s,'RS232?','async')
pause(10)
fclose(s)
delete(s)
clear s
-----------------------------------------------------------------
based on http://www.mathworks.com/access/helpdesk/help/toolbox/instrument/f20-73779.html

by that tutorial, this must return

OutputEmpty event occurred at 17:37:21 for the object:
Serial-COM1.
....

but my code does not.
-Yet, 'BytesAvailableFcn' works ok...
-synchronous write works OK; data sent with asynchronous reaches device- only callback is not working
-this does not depend on com port
-this seems to be really asynchronous, due to if I double "fprintf(s,'RS232?','async')" string matlab returns:
??? Error using ==> serial.fprintf at 144
An asynchronous write is already in progress.

Any ideas?