function xpc_openwwwinterface()
% XPC_OPENWWWINTERFACE opens Browser and activate the WWW-Server of xPC
%
% XPC_OPENWWWINTERFACE is a function for help the user to open the
% WWW-Interface which is in every Target Application of xPC based
% Systems implemented at code generation. These is a quick way to open
% the Browser. Of course could the User enter manually the IP-Address
% into the URL-Address into the Browser as well as the Portnumber. But if
% both information is not ready to use then the user lost some time to
% setup and open these easy-and-usefull Interface.
%
% It checks automatically the connection between Host and Target. If it
% detect TCP/IP Connection then it will with the saved TcpIpTargetAddress
% and TcpIpTargetPort in the MAT-File xpcenv.mat open the default
% installed Internet Browser to be able to drive the xPC Application
% through these Interface.
% These function check if either RS2323 or TcpIp is set as Host-Target
% Communication. If a RS232 Connection is detected, then it will be also
% automatically call in correct way the Serial-TCP/IP Emulator to be able
% to use at any case the WWW-Interface through the installed Browser.
%
% Syntax: >> xpc_openwwwinterface
%
% See also: XPC_COMMAND_CENTER XPC_QUICK_REFERENCE NEWXPC
%% AUTHOR ..... : Frank Gonzalez-Morphy
%% DATE ....... : 22-Aug-2001 17:37:39
%% UPDATES .... : 15-Aug-2004 17:23:38
%% $Revision .. : 4.00 $
%% DEVELOPED .. : R12.0 -> R12.1 -> R13.0 -> R14.0
%% Filename ... : xpc_openwwwinterface.m
%% Another Comments from Author:
%% - If you encounter problems while calling Internet Explorer and the
%% connection is not done. IE is trying to open Proxy, then the Solution
%% is to stop it, in IE under EXTRAS -> Internetoptions -> Connections
%% (Verbindungen) and under "LAN Settings" disable the checkbox
%% "use Proxyserver" !! Then after clicking on OK, and recall the IP-
%% Address you will get the xPC-WWW-Server Connection !!!
% Check if Target is connected
if strcmp(xpctargetping,'success')
% Get the Communication kind between Host and Target
Host_Target_Comm = getxpcenv('HostTargetComm');
HTC = Host_Target_Comm;
if strcmp(HTC,'RS232') % Connection is Serial through RS232
disp(' ')
disp(' MSG: **Serial** Communication to Target detected ...')
port = open_xpc_serial; % Call Serial Setup Function
ip = 'localhost';
else
if strcmp(HTC,'TcpIp') % Connection detection was TCP/IP
disp(' ')
disp(' MSG: **TCP/IP** Communication to Target detected ...')
% Call TCP/IP setup Function to extract IP-Address
[ip, port] = open_xpc_tcpip;
end
end
disp(' MSG: Closing MATLAB Connection to Target.')
close(xpc);
xpcapp_adr = ['http://' ip ':' port];
web(xpcapp_adr, '-browser')
disp(' MSG: Browser should be openned.')
disp([' MSG: Manual command is: web(''' xpcapp_adr ''', ''-browser'' )'])
disp(' MSG: === END === ')
disp(' ')
else
msgbox('Problems encounter while executing XPC_OPENWWWINTERFACE', 'Connection ERROR to Target happens', 'error')
end
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%% OPEN_XPC_TCPIP %%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ip, port] = open_xpc_tcpip()
% Enable the use of the xPC Target WWW Interface
% xpcwwwenable % gives connection free for usage through another Tools
% % close(xpc) % gives connection free for usage through another Tools
% GET all xPC Environment Settings
env = getxpcenv;
actenv = env.actpropval';
% Environment Setting 14 = TcpIpTargetAddress
ip = char(actenv(14));
% Environment Setting 15 = TcpIpTargetPort
port = char(actenv(15));
return
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%% OPEN_XPC_SERIAL %%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function TCPport = open_xpc_serial()
% OPEN_XPC_SERIAL does call the Serial to TCP/IP Emulator to be able to
% communicate through the Browser to the WWW-Interface using RS232 cable.
%% AUTHOR : Frank Gonzalez-Morphy
%% $DATE : 26-Mar-2003 15:54:53 $
%% $Revision : 1.00 $
%% DEVELOPED : R13.0
%% FILENAME : open_xpc_serial.m
% Close openned connection to Target
% % close(xpc) % gives connection free for usage through another Tools
% -v VERBOSE | -t USE TCP PORT {22222}
tcp2rs232_path = '\toolbox\rtw\targets\xpc\xpc\bin\';
tcp2rs232_call = 'xpctcp2ser -v -t ';
TCPport = getxpcenv('TcpIpTargetPort');
COMx = getxpcenv('RS232HostPort');
COM_Nr = COMx(1,4); % Get only the number of COM-Port
COM = [' -c ', COM_Nr, ' &'];
tcp2rs232_call = [tcp2rs232_call, TCPport, COM];
tcp2rs232_cmd = [tcp2rs232_path, tcp2rs232_call];
msg = [' MSG: Opening xPC Target TCP/IP to RS232 Gateway'];
disp(msg);
disp([' ', tcp2rs232_call]);
cmd = [matlabroot, tcp2rs232_cmd];
% ..... These shows the executions status on the Command Window
fprintf(2,' ');
for i=1:8
fprintf(2,'.');
pause(1)
end
[res, echo] = dos(cmd); % Execute the complete command in DOS
disp(' ')
% Connecting COM1 to TCP port 22222
%
if findstr(echo,'COM') == 0
msgbox('Problems encounter starting xpcTCP2SER', 'Connection ERROR to Target happens', 'error')
error(' MSG: COM Port not readable !')
end
% ORIGINAL COMMAND from DOS:
% ===========================
% Microsoft Windows 2000 [Version 5.00.2195]
% (C) Copyright 1985-1999 Microsoft Corp.
%
% 12:58 C:\Temp >> d:\matlab65\toolbox\rtw\targets\xpc\xpc\bin\xpctcp2ser -v -t 22222 -c 1
%
% *-------------------------------------------------------------*
% * xPC Target TCP/IP to RS232 gateway. *
% * *
% * Copyright (c) 2000 The MathWorks, Inc. All Rights Reserved. *
% *-------------------------------------------------------------*
%
% Connecting COM1 to TCP port 22222
% ...
% ...
% ===========================
% --- EOF --- [xpc_openwwwinterface.m] ---