GetChannelStatus

<< Click to Display Table of Contents >>

Navigation:  Reference (Scripting) > Docklight Script Commands - The DL Object > Methods (Advanced) >

GetChannelStatus

Returns the current communication channel status (closed, open, waiting for TCP connection, or error).

 

Return Value

 

Integer

 

Syntax

 

result = DL.GetChannelStatus( [channelNo] )

 

The GetChannelStatus method syntax has these parts:

 

Part

Description

channelNo

Optional. Integer that specifies the communication channel if Communication Mode: Monitoring or Side Channels are used. Default value is 1 (Channel 1).

 

Remarks

 

GetChannelStatus returns the following values:

 

result

Description

0

Channel is closed, communications is stopped (see also StopCommunication)

1

Channel is open and ready to transmit/receive data.

TCP server or TCP client mode: Connection established.

2

TCP server or TCP client mode: Waiting for connection.

COM port with RTS/CTS hardware flow control: Waiting for handshake signal.

3

Channel error, e.g. after a SetChannelSettings command that specified a non-existing COM port number.

 

See also SetChannelSettings and GetChannelSettings.

 

Example

 

' Example GetChannelStatus

' (requires Docklight in Send/Receive mode)

 

DL.ClearCommWindows

 

DL.AddComment "COM port access"

DL.SetChannelSettings "COM3:9600,NONE,8,1", 1

DL.AddComment "GetChannelStatus before StartCommunication = " & DL.GetChannelStatus(1)

DL.StartCommunication

DL.AddComment "GetChannelStatus after StartCommunication = " & DL.GetChannelStatus(1)

DL.StopCommunication

 

DL.AddComment

DL.AddComment "TCP client mode"

DL.AddComment "Connecting to docklight.de ..."

DL.SetChannelSettings "docklight.de:80", 1

DL.StartCommunication

' wait until connected

Do

   commStatus = DL.GetChannelStatus(1)

   DL.AddComment "GetChannelStatus = " & commStatus

   DL.Pause 10

Loop Until commStatus <> 2

If commStatus = 1 Then

   DL.AddComment "Connected."

Else

   DL.AddComment "Error!"

End If

DL.StopCommunication

 

After running the script on a computer with a built-in COM3 port (e.g. modem) and Internet connection, the communications window could look like this:

 

COM port access

GetChannelStatus before StartCommunication = 0

GetChannelStatus after StartCommunication = 1

 

TCP client mode

Connecting to docklight.de ...

GetChannelStatus = 2

GetChannelStatus = 2

GetChannelStatus = 2

GetChannelStatus = 2

GetChannelStatus = 1

Connected.