How to define input parameters for BytesAvailableFcn (tcpclient)
Hy all,
my problem concerns the use of input arguments when I define the BytesAvailableFcn of a tcpclient connection.
I create a tcpclient connection:
t = tcpclient(‘address’, port);
And I send a request to the server (which starts automatically to send data):
write( t, ‘request’ );
I want to have a callback function triggered by a bytes available event:
configureCallback( t, "terminator", @MyCallbackFcn );
MyCallbackFcn is written in a separated MyCallbackFcn.m file. The callback function MyCallbackFcn is triggeredd whenever a terminator is available to be read from the remote host specified by the TCP/IP client.
At the moment, MyCallbackFcn uses global parameters (var1, var2, etc.) defined in the main program:
function MyCallbackFcn( src, ~ )
global var1 var2
…
end
This algorithm works well. But in order to avoid the use of global parameters, I would like to define input parameters for MyCallbackFcn fonction. My problems start here, because I do not find the right form to write:
the definition of the callback function in the main program : configureCallback( t,…
the function MyCallbackFcn in the MyCallbackFcn.m file
Thank you in advance for your help.
RaphaëlHy all,
my problem concerns the use of input arguments when I define the BytesAvailableFcn of a tcpclient connection.
I create a tcpclient connection:
t = tcpclient(‘address’, port);
And I send a request to the server (which starts automatically to send data):
write( t, ‘request’ );
I want to have a callback function triggered by a bytes available event:
configureCallback( t, "terminator", @MyCallbackFcn );
MyCallbackFcn is written in a separated MyCallbackFcn.m file. The callback function MyCallbackFcn is triggeredd whenever a terminator is available to be read from the remote host specified by the TCP/IP client.
At the moment, MyCallbackFcn uses global parameters (var1, var2, etc.) defined in the main program:
function MyCallbackFcn( src, ~ )
global var1 var2
…
end
This algorithm works well. But in order to avoid the use of global parameters, I would like to define input parameters for MyCallbackFcn fonction. My problems start here, because I do not find the right form to write:
the definition of the callback function in the main program : configureCallback( t,…
the function MyCallbackFcn in the MyCallbackFcn.m file
Thank you in advance for your help.
Raphaël Hy all,
my problem concerns the use of input arguments when I define the BytesAvailableFcn of a tcpclient connection.
I create a tcpclient connection:
t = tcpclient(‘address’, port);
And I send a request to the server (which starts automatically to send data):
write( t, ‘request’ );
I want to have a callback function triggered by a bytes available event:
configureCallback( t, "terminator", @MyCallbackFcn );
MyCallbackFcn is written in a separated MyCallbackFcn.m file. The callback function MyCallbackFcn is triggeredd whenever a terminator is available to be read from the remote host specified by the TCP/IP client.
At the moment, MyCallbackFcn uses global parameters (var1, var2, etc.) defined in the main program:
function MyCallbackFcn( src, ~ )
global var1 var2
…
end
This algorithm works well. But in order to avoid the use of global parameters, I would like to define input parameters for MyCallbackFcn fonction. My problems start here, because I do not find the right form to write:
the definition of the callback function in the main program : configureCallback( t,…
the function MyCallbackFcn in the MyCallbackFcn.m file
Thank you in advance for your help.
Raphaël tcpclient, bytesavailablefcn, input parameters MATLAB Answers — New Questions