Command-Phase (TCP) Programming

Top  Previous  Next

 

Another method of programming is called command-phase programming. As explained in network programming it only works when the current Transport Protocol (TP) [setting/parameter] is 1 (TCP) and the Data Login (DL) setting is 1 (enabled). In this mode, the TCP data connection between the network host and the DS is split into two phases: command phase and data phase.

 

When the Data Login (DL) setting is 1 (enabled) and the data TCP connection is established the DS enters the command phase. In this phase the DS interprets all data sent by the network host as programming commands. Because no routing data can be transmitted in this phase an escape character (like the one used in the inband programming) is not needed.

 

All command-phase commands and replies use the following format:

 

STX

Command/reply

CR

 

Thus, command-phase commands and replies have the same format as those used in serial programming. STX (ASCII code 2) and CR (ASCII code 13) characters provide necessary encapsulation. All data before the STX and after the CR is ignored. Command/reply field contents has been explained in programming.

 

To switch the data connection from the command phase into the data phase the network host has to issue the Logout (O) command. After this command is sent* and accepted the DS switches into the data phase. From this moment on and until the TCP connection is terminated the network host can exchange the data with the attached serial device in the normal way.

 

Logout (O) command is only accepted after the network host logs in using Login (L) command, and this requires a valid password (if set in the Password (PW) setting). Therefore, setting Data Login (DL) to 1 (enabled) also enables network host authentication for data exchange with the attached serial device(hence, the name of this setting).

 

Example: here is a sample exchange that switches the DS into the data phase. Shown below is the data passed within a data TCP connection. Special characters are represented as follows: STX- J, CR- . Login password is "123pwd"

 

---TCP connection established, command phase---

Host-->DS:        JL123pwd                'network host logs in

DS-->Host:        JA                        'OK

Host-->DS:        JO                        'exit into the data phase (no reply)

---data phase from this point and until the TCP connection is closed---

 

Command-phase programming should not be confused with inband programming. The first one is enabled by the Data Login (DL) setting, the second one- by the Inband (IB) setting. Both can be enabled at the same time! After the DS exits into the data phase inband commands can still be sent (this time, with proper escape character), provided that inband programming is enabled.

 

Command-phase programming is disabled automatically when current Link Service Login (TL) [setting/parameter] is 0 (disabled).

 

*Command-phase inband programming is the only programming method in which no reply is returned upon successful completion of the Logout (O) command. The DS simply switches into the data phase.