Inband (TCP) Programming
|Top Previous Next|
Inband commands and replies are sent within the TCP data connection itself and can be mixed with the data being routed between the network host and attached serial device. As explained in network programming this method only works when the current Transport Protocol (TP) [setting/parameter] is 1 (TCP) and the Inband (IB) setting is 1 (enabled).
Since inband commands and replies are intermixed with the data a special escape character called Inband Escape Character (IEC) is needed to mark the beginning of the command (reply) in the data stream. IEC code is 255. When the Inband (IB) setting is 1 (enabled) and the DS receives a character with code 255 followed by any character other than 255, the DS considers this to be a beginning of the inband command. If the network host wants to send a data character with code 255 it needs to send two consecutive characters with code 255. This will be interpreted by the DS as a single data character with code 255. Therefore, it is the responsibility of the network host to parse through the data it is sending to the DS and "double" all data characters with code 255.
When sending a reply back to the network host, the DS will also prefix this reply with the IEC. When sending a data byte with code 255 the DS will automatically double this character. It is the responsibility of the network host to parse through the data it receives from the DS and replace all double characters with code 255 with a single one.
All inband commands and replies use the following format:
IEC character followed by STX (ASCII code 2) mark the beginning of command (reply). CR (ASCII code 13) marks the end of command (reply). All characters before the IEC/STX and after the CR are considered to be a "regular" routing data. Command/reply field contents has been explained in programming.
Example: here is a sample exchange between the network host and the DS. Shown below is the data passed within a data TCP connection. Special characters are represented as follows: IEC- u, STX- J, CR- Ã.
In the above exchange the network host is sending the following data string: "ABCuDEFGHIK". There is a single character with code 255 (u) but the DS has to double this character. Command inserted into this data stream is "GIP" (Get Setting (G) command, setting to be read is IP-address (IP)). Command is preceded with IEC (u)followed by STX (J) and ended by CR (Ã).
The DS sends the following data string to the network host: "LMNXYZ". At some point, when the reply to the command is ready, the DS inserts this reply into the data stream. Reply contains current IP-address of the DS.
Unlike out-of-band UDP programming, inband programming does not support multiple commands. It is not possible to send several commands and receive several replies back. The network host should only send the next command after having received a reply to the previous command.
Very important! Since inband commands are transmitted together with data execution of such commands by the DS can be delayed indefinitely if the data cannot be transmitted by (sent out of) the serial port of the DS. This will happen if current Flow Control (FC) [setting/parameter] is at 1 (enabled) and the CTS input of the DS is held in the "do not transmit" state. In this case the DS will not be sending out data and the inband command "embedded" within this data stream won't be processed (until all data before this command is finally transmitted).