I use DL.SetChannelSettings(“COMxx”) to check if my COM port is available, but I still receive an error when opening the port using DL.StartCommunication() (Windows Error #5 – Access is Denied).

I use DL.SetChannelSettings(“COMxx”) to check if my COM port is available, but I still receive an error when opening the port using DL.StartCommunication() (Windows Error #5 – Access is Denied).

Applies to: Docklight Scripting V2.3.26 or earlier, Article ID: dl_prb053

The DL.SetChannelSettings() does not perform the ‘open port’ test according to the user manual, if the COM port number in the argument is the same than what is currently set.

This is indeed a bug in DL.SetChannelSettings(..) in Docklight Scripting V2.3.26 or earlier which appears only in this specific situation, and unfortunately was not covered by our automated release testing.

We will correct the behavior in the next update, but there is also a straightforward workaround, which will remain compatible with any future Docklight versions. Simply use an extra line to move the COM setting to a different / unused port number before the actual test, e.g:

DL.SetChannelSettings “COM255”, 1, False
portAvailable = DL.SetChannelSettings(“COM7”)

This will make sure the second DL.SetChannelSettings call will actually open the port for testing.

Docklight Manual – SetChannelSettings