Use TCPIP with callback inside a class

2 visualizaciones (últimos 30 días)
Matti Kaupenjohann
Matti Kaupenjohann el 27 de En. de 2020
I have a problem with a the tcpipsocket in use with a class as property. The class inherits handle to work with constructor and destructor. All works fine until I activate the BytesAvailableFunction. After the Activation the destructor will no longer be called by deleting my workspace. It seems that my class is referenced somewhere in the instrument control, because calling instrreset after deleting my workspace, calls my destructor function.
Here is a minimal example that reproduce the error:
classdef wsg50_mini2 < handle
properties
TCPIP
end
%PUBLIC METHODS
methods
%CONSTRUCTOR
function obj = wsg50_mini2(varargin)
fprintf('################# I am created #################\n')
obj.TCPIP = tcpip('localhost',1000);
obj.TCPIP.OutputBufferSize = 3000;
obj.TCPIP.InputBufferSize = 3000;
obj.TCPIP.ByteOrder = 'littleEndian';
obj.TCPIP.Timeout = 1;
%Setting up Callbackfunction
obj.TCPIP.BytesAvailableFcnMode = 'byte';
obj.TCPIP.BytesAvailableFcnCount = 1;
obj.TCPIP.BytesAvailableFcn = {@obj.TCP_Callback, obj};
end
end
%PRIVATE METHODS
methods (Access = private)
%DESTRUCTOR
function delete(obj)
fprintf('################# Hey I am called! #################\n')
instrreset
end
end

Respuestas (0)

Categorías

Más información sobre App Building en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by