MATLAB: How to check if the TCP/IP connection between the host and the target is active using the COM API in xPC Target 3.4 (R2008a)

Simulink Real-Time

Once I connect to the Target using the TcpIpConnect method, I would like to periodically check to make sure I'm still connected to the target.
If I use "xPCProtocol.TargetPing" the connection between the host and the target is lost and I will have use "xPCProtocol.TcpIpConnect" to re-establish the TCP/IP connection between the host and the target.

Best Answer

A workaround for this issue is to query the name of the application deployed onto the target using the "xPCTarget.GetAppName" method. If this method returns an error, the connection is not active. If this method returns a string with the name of the target application, then the connection is active.