beckhoff TE1000 TwinCAT 3 — 6.3.11 Finding targets using broadcast search

Samples | System Requirements A TwinCAT solution is open. The target system is accessible on the network. General broadcast search for all devices C#: string xmlString = " true TargetList> "; ITcSmTreeItem routes = sysMan.LookupTreeItem("TIRR"); routes.ConsumeXml(xmlString); string result = routes.ProduceXml(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(result); string amsNetId = xmlDocument.SelectSingleNode("//TreeItem/RoutePrj/TargetList/Target/ IpAddr[text()=\"" + ipAddress + "\"]/../NetId").InnerText; string name = xmlDocument.SelectSingleNode("//TreeItem/RoutePrj/TargetList/Target/ IpAddr[text()=\"" + ipAddress + "\"]/../Name").InnerText; PowerShell:

$xmlString = " true RoutePrj> " $routes = $systemManager.LookupTreeItem("TIRR") $routes.ConsumeXml($xmlString) $result = $routes.ProduceXml() $xmlDocument = [xml]$result $localAmsNetId = $xmlDocument.TreeItem.RoutePrj.Target The variable result contains an XML representation of all ADS devices found on the network. You can select a specific device from this list: Direct broadcast search starting with TwinCAT 3.1 Build 4020.10 C# sample:

ITcSmTreeItem routeNode = sysManager.LookupTreeItem("TIRR"); // Search by IP address string searchXml = @" 192.168.1.100 "; routeNode.ConsumeXml(searchXml); string resultXml = routeNode.ProduceXml(); // Parse result var doc = new System.Xml.XmlDocument(); doc.LoadXml(resultXml); var netIdNode = doc.SelectSingleNode("//Target/NetId"); string amsNetId = netIdNode?.InnerText; PowerShell sample: $routeNode = $sysManager.LookupTreeItem("TIRR") $searchXml = " CX-12345 TreeItem>" $routeNode.ConsumeXml($searchXml) [xml]$result = $routeNode.ProduceXml() $target = $result.TreeItem.RoutePrj.TargetList.Target Write-Host "Name: $($target.Name)" Write-Host "NetId: $($target.NetId)" Write-Host "IP:

$($target.IpAddr)" XML structure of the broadcast search: CX-12345 TE1000 212 Version: 1.7.0