xPC Target    

Connecting the Web Interface Through RS-232

If the host PC and target PC are connected with a serial cable instead of a network cable, you can still connect the target application on the target PC to a Web browser on the host PC. xPC Target includes a TCP/IP to RS-232 mapping application. This application runs on the host PC and writes whatever it receives from the RS-232 connection to a TCP/IP port, and it writes whatever is receives from the TCP/IP port to the RS-232 connection. TCP/IP port numbers must be less than 216 = 65536.

Before you connect your Web browser on the host PC, you must load a target application onto the target PC. The target application does not have to be running, but it must be loaded. Also, your Web browser must have JavaScript and StyleSheets turned on.

  1. In the MATLAB window, type
  1. MATLAB is disconnected from the target PC, leaving the target PC ready to connect to another client. The TCP/IP stack of the xPC Target kernel supports only one simultaneous connection. If you do not use this command, the TCP/IP to RS-232 gateway might not be able to connect to the target PC.

  1. Open a DOS command window, and enter the command to start the TCP/IP to RS-232 gateway. For example, if the target PC is connected to COM1 and you would like to use the TCP/IP port 22222, type the following:
  1. The TCP/IP to RS-232 gateway starts running, and the DOS command window displays the message

    If you did not close the MATLAB to target application connection, then xpxtcp2ser displays the message Could not initialize COM port.

  1. Open a Web browser. In the address box, enter
  1. The Web browser loads the xPC Target Web interface pages.

  1. Using the Web interface, start and stop the target application, add scopes, add signals, and change parameters.
  2. In the DOS command window, press Ctrl+C.
  1. The TCP/IP to RS-232 Gateway stops running, and the DOS command window displays the message

    The gateway application has a handler that responds to Ctrl-C by disconnecting and shutting down cleanly. In this case, Ctrl-C is not used to abort the application.

  1. In the MATLAB Command Window, type
  1. MATLAB reconnects to the target application and lists the properties of the target object.

    If you did not close the gateway application, MATLAB displays the message

    To correct this problem, you must close MATLAB and then restart it.

Syntax for the xpctcp2ser Command

The syntax for the xpctcp2ser command is

The options are described in the following table.

Command-
Line Option

Description
-v
Verbose mode. Produces a line of output every time a client connects or disconnects.
-n

Allows nonlocal connections. By default, only clients from the same computer that the gateway is running on are allowed to connect. This option allows anybody to connect to the gateway.

If you do not use this option, only the host PC that is connected to the target PC with a serial cable will be able to connect to the selected port. For example, if you start the gateway on your host PC, with the default ports, you can type in the Web browser http://localhost:2222 . However, if you try to connect to http://Domainname.com:22222, you will probably get a connection error.

-t tcpPort
Use TCP port tcpPort. Default t is 22222. For example, to connect to port 20010, type -t 20010.
-h
Print a help message.
-c comPort
Use COM port comPort (1 <= comPort <= 4). Default is 1. For example, to use COM2, type -c 2.


  Connecting the Web Interface Through TCP/IP Using the Main Page