ethercat-linux/scripts/tc-dump-mapping.ps1

20 lines
819 B
PowerShell
Raw Permalink Normal View History

#Requires -RunAsAdministrator
$ErrorActionPreference = 'Continue'
$dte = New-Object -ComObject TcXaeShell.DTE.17.0
$dte.MainWindow.Visible = $true
try { $dte.SuppressUI = $false } catch {}
$dte.Solution.Open('C:\Users\tonycao\work\twincat3-auto-cli\TwinCAT_EL6695_Primary\TwinCATProject1.sln')
Start-Sleep 20
$sm = $null
for ($i = 0; $i -lt 20; $i++) {
try { $sm = $dte.Solution.Projects.Item(1).Object; if ($sm) { break } } catch {}
Start-Sleep 3
}
if (-not $sm) { Write-Host 'no sysmgr'; exit 1 }
try { $sm.SetTargetNetId('169.254.176.217.1.1') } catch {}
Start-Sleep 2
$xml = $sm.ProduceMappingInfo()
Write-Host "mapping info length: $($xml.Length)"
[System.IO.File]::WriteAllText('C:\Users\tonycao\work\ethercat-linux\tmp_mapping.xml', $xml, [System.Text.Encoding]::UTF8)
Write-Host 'saved tmp_mapping.xml'