adsplctwincattwincat-ads

TwinCAT 3.0 Broadcast search without Automation Interface


Is there any way to perform a broadcast search using the general TwinCAT.Ads.* namespace? Using the automation system for this seems extremely overkill, not to mention that it takes almost a full minute to initialize the EnvDTE, generate a solution, and finally be able to do the search.

Even just finding a way to get a list of the currently configured routes would probably be good enough.

The TwinCat 3 service in the sys-tray seems to be able to do it without this extra baggage, so I'm hoping there's some public interface for this. It will have the added benefit of not needing references to the Visual Studio SDK.


Solution

  • There is a file C:\TwinCAT\3.1\Target\StaticRoutes.xml which contains all the active static routes of that computer. At least I have always though so. So I think that the system tray service just reads that file?

    Of course, that doesn't tell you if the route is really in operation. About that I have no idea.

    You can just parse the XML. Example of the file contents:

    <?xml version="1.0" encoding="UTF-8"?>
    <TcConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <RemoteConnections>
            <Route>
                <Name>PLC_1</Name>
                <Address>192.168.1.2</Address>
                <NetId>192.168.1.2.1.1</NetId>
                <Type>TCP_IP</Type>
            </Route>
            <Route>
                <Name>PLC_2</Name>
                <Address>192.168.1.3</Address>
                <NetId>192.168.1.3.1.1</NetId>
                <Type>TCP_IP</Type>
            </Route>
        </RemoteConnections>
    </TcConfig>