ReadWrite

ADS ReadWrite requests send data to the ADS Server and get a Data response in one roundtrip. The Powershell command to request an ADS ReadWrite is the Send-TcReadWrite Cmdlet.

Send an ADS ReadWrite Request with IndexGroup/IndexOffset (Return Data as string)

PS> Send-TcReadWrite -NetId 1.2.3.4.5.6 -Port 851 -IndexGroup SymbolValueByName -IndexOffset 0 -WriteValue "TwinCAT_SystemInfoVarList._AppInfo.ProjectName" -ReadType string -ReadLength 1024 

ReadWrite access of process image on target '1.2.3.4.5.6:851':
Start ReadWrite operation WriteData: 'TwinCAT_SystemInfoVarList._AppInfo.ProjectName'(IG:0xf004,IO:0x0000,Len:47),
Read: Type 'System.String' (Len:'1024) on target '1.2.3.4.5.6:851'?
[Y] Yes[A] Yes to All[N] No[L] No to All[S] Suspend[?] Help(default is "Y"): y
ADS_DynSymbols

Sends a Read/Write request with index group 0xf004 (SymbolValueByName) and offset 0.

The write data will be initialized with the project symbol path and an returned (read) string (Default encoded) returned.

Send an ADS ReadWrite Request with IndexGroup/IndexOffset (return data as byte{})

PS> Send-TcReadWrite -NetId 1.2.3.4.5.6 -Port 851 -IndexGroup SymbolValueByName -WriteValue "TwinCAT_SystemInfoVarList._AppInfo.ProjectName" -ReadLength 64 | format-hex

ReadWrite access of process image on target '1.2.3.4.5.6:851':
Start ReadWrite operation WriteData: 'TwinCAT_SystemInfoVarList._AppInfo.ProjectName'(IG:0xf004,IO:0x0000,Len:47),
Read: Type 'System.Byte[]' (Len:'64) on target '1.2.3.4.5.6:851'?
[Y] Yes[A] Yes to All[N] No[L] No to All[S] Suspend[?] Help(default is "Y"): y


00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000   41 44 53 5F 44 79 6E 53 79 6D 62 6F 6C 73 00 00  ADS_DynSymbols..
00000010   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000020   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000030   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

Sends a Read/Write request with index group 0xf004 (SymbolValueByName) and offset 0.

The write data will be initialized with the project symbol path and the returned (read) data is by default a byte array of 64 bytes.

The result value will be formatted as hex code.

Send an ADS ReadWrite Request with IndexGroup/IndexOffset (using handle)

PS> $route = Get-AdsRoute -Name 'CX-123456'
PS> $session = $route | New-TcSession -Port 851
PS> $handle = $session | Send-TcReadWrite -IndexGroup SymbolHandleByName -WriteValue "GVL.vgInt" -ReadType Int32 -force
PS> $session | Read-TcValue -IndexGroup SymbolValueByHandle -IndexOffset $handle -ValueType Int16
42

Create a session to the PLC (Port 851) of a target system, determine the SymbolHandle by InstancePath and use this handle to read its 'Int16' Value (INT on PLC System).