How To | Reading / Writing Data 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).
5.9.4 Calling RpcMethods and accessing PLC Properties | Calling RpcMethods and accessing PLC Properties RpcMethods can be directly called type safe on the value dynamically read by a symbolic Read-TcValue. The RpcMethod In-/ and Out-/ Parameters are automatically marshalled to/from they .NET counterparts – so that the access is easy and transparently. Accessing the RPC Methods needs to open an ADS Session and loading the symbolic information. Here we open a new session to the local PLC. PS> $session = new-tcSession -port 851 PS> $rpcSymbol | Get-TcSymbol -path 'MAIN.fbRpc' The ‘rpcSymbol’ object now contains the Symbol of the FB instance ‘fbRcp’.
This FB has a RpcMethod ‘AddValues’ with 2 INT parameters and a Property ‘PropInt’ defined (on the PLC side). Information about these defined symbol instance can be browsed. PS> $rpcSymbol InstancePath Category DataType Size Static Persistant IG IO ------------ -------- -------- ---- ------ ---------- -- -- MAIN.fbRpc Struct FB_RpcPou 1152 False False 4040 10DEE8 Beneath Properties and Methods of the Instance base class, the ‘rpcSymbol’ contains dynamically generated access properties and methods. PS> $rpcSymbol | Get-Member TypeName:
TwinCAT.TypeSystem.DynamicStructInstance Name MemberType Definition ---- ---------- ---------- AddValues Dynamic dynamic AddValues AddValuesAsync Dynamic dynamic AddValuesAsync PropInt Dynamic dynamic PropInt Accessing the Rpc Method metadata of the symbol: PS> $rpcSymbol.RpcMethods Name ReturnType Declaration TE1000 27 Version: 1.5.0