Use TCPIP with callback inside a class

2 ビュー (過去 30 日間)
Matti Kaupenjohann
Matti Kaupenjohann 2020 年 1 月 27 日
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

回答 (0 件)

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by