Effacer les filtres
Effacer les filtres

Use TCPIP with callback inside a class

1 vue (au cours des 30 derniers jours)
Matti Kaupenjohann
Matti Kaupenjohann le 27 Jan 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

Réponses (0)

Catégories

En savoir plus sur Software Development Tools dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by