Finding Out Connection Status (X)

Top  Previous  Next

 

The Echo (X) command causes the DS to return a string full of status information. The contents of this string is fully documented in the manual page for the command, so we will only take up the part which is pertinent to this AN: Data Connection Status.

 

Following is a quote from the manual page for the command, restructured for the purposes of this AN.

 

When issued using the serial programming mode, the reply for this command looks like this:

 

Amseic[p]/ES

 

For now, we only care about the bold c which appears near the middle of the command (it is the 6th character). You can read about the meaning of the other letters in the command manual page. The c stands for "data connection status". This is just a position in the reply string of this command -- it does not actually say c in the command (otherwise, how could it be used to detect a status? Naturally, it must change.) Thus, this position in the reply string for the command can contain one of the following characters:

 

*                Data connection is currently closed.

 

A                Sending ARP, or (V3.54+) establishing PPP link (using PPPoE).

 

O                A data connection is being established

 

C                A TCP connection is currently established, or is being closed (but not yet closed).

 

U                A UDP connection is currently established.

 

R                The connection was reset by the remote host -- no connection at the moment.

 

F                LinkServer login failed.

 

L                LinkServer login is currently in progress.

 

A Practical Example

 

Let's say you have a serial device and wish to make an outbound connection to a server. To do so, you need to first check if it is safe to try and connection (i.e, that there isn't an active data connection at the moment). Then, you have to issue the connection command. Then, you have to check that the connection has indeed been established, and continue checking periodically until the connection is established.

 

Such a programming session could look like this (bold lines are commands sent to DS):

 

Checking -- is there an established data connection?

 

<STX>X<CR>        

 

The 6th char (c) is an asterisk - Data connection currently closed. Proceeding:

 

<STX>ANS*I**/**<CR>        

 

Establish a connection with 192.168.0.20:1001:

 

<STX>PCE192.168.0.5/1001<CR>        

 

DS acknowledges command:

 

<STX>A<CR>        

 

Checking -- is there an established data connection?

 

<STX>X<CR>        

 

The 6th char (c) is O - Data connection being established. We are still not connected:

 

<STX>ANS*IO*/**<CR>        

 

(After waiting for some time):

 

Checking -- is there an established data connection?

 

<STX>X<CR>        

 

The 6th char (c) is C - We have a TCP connection, verified:

 

<STX>ANS*IC*/**<CR>

 

Logging out of programming mode to start communicating:

 

<STX>O<CR>        

 

DS acknowledges command:

 

<STX>A<CR>        

 

The Example, Illustrated:

 

an010 connection