Read-TcValue

SYNOPSIS

Reads values from TwinCAT devices.

SYNTAX

NetIdPortSymbol (Default)

Read-TcValue [-NetId <AmsNetId[]>] -Port <Int32> [-Path] <String> [-Extended] [-Force] [-Timeout <Int32>]
 [-Encoding <Encoding>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

NetIdPortIndexed

Read-TcValue [-NetId <AmsNetId[]>] -Port <Int32> [-IndexGroup] <UInt32> [[-IndexOffset] <UInt32>]
 [-Size] <Int32> [-Force] [-Timeout <Int32>] [-Encoding <Encoding>] [-ProgressAction <ActionPreference>]
 [<CommonParameters>]

NetIdPortIndexedTyped

Read-TcValue [-NetId <AmsNetId[]>] -Port <Int32> [-IndexGroup] <UInt32> [[-IndexOffset] <UInt32>]
 [-ValueType] <Type> [-Size] <Int32> [-Force] [-Timeout <Int32>] [-Encoding <Encoding>]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

RouteIndexed

Read-TcValue -Route <IRoute[]> -Port <Int32> [-IndexGroup] <UInt32> [[-IndexOffset] <UInt32>] [-Size] <Int32>
 [-Force] [-Timeout <Int32>] [-Encoding <Encoding>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

RouteIndexedTyped

Read-TcValue -Route <IRoute[]> -Port <Int32> [-IndexGroup] <UInt32> [[-IndexOffset] <UInt32>]
 [-ValueType] <Type> [[-Size] <Int32>] [-Force] [-Timeout <Int32>] [-Encoding <Encoding>]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

RouteSymbol

Read-TcValue -Route <IRoute[]> -Port <Int32> [-Path] <String> [-Extended] [-Force] [-Timeout <Int32>]
 [-Encoding <Encoding>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

AddressIndexed

Read-TcValue -Address <String[]> -Port <Int32> [-IndexGroup] <UInt32> [[-IndexOffset] <UInt32>] [-Size] <Int32>
 [-Force] [-Timeout <Int32>] [-Encoding <Encoding>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

AddressIndexedTyped

Read-TcValue -Address <String[]> -Port <Int32> [-IndexGroup] <UInt32> [[-IndexOffset] <UInt32>]
 [-ValueType] <Type> [[-Size] <Int32>] [-Force] [-Timeout <Int32>] [-Encoding <Encoding>]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

AddressSymbol

Read-TcValue -Address <String[]> -Port <Int32> [-Path] <String> [-Extended] [-Force] [-Timeout <Int32>]
 [-Encoding <Encoding>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

SessionIndexed

Read-TcValue -Session <ISession[]> [-IndexGroup] <UInt32> [[-IndexOffset] <UInt32>] [-Size] <Int32> [-Force]
 [-Timeout <Int32>] [-Encoding <Encoding>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

SessionIndexedTyped

Read-TcValue -Session <ISession[]> [-IndexGroup] <UInt32> [[-IndexOffset] <UInt32>] [-ValueType] <Type>
 [[-Size] <Int32>] [-Force] [-Timeout <Int32>] [-Encoding <Encoding>] [-ProgressAction <ActionPreference>]
 [<CommonParameters>]

SessionSymbol

Read-TcValue -Session <ISession[]> [-Path] <String> [-Extended] [-Force] [-Timeout <Int32>]
 [-Encoding <Encoding>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

SessionIdIndexed

Read-TcValue -SessionId <Int32[]> [-IndexGroup] <UInt32> [[-IndexOffset] <UInt32>] [-Size] <Int32> [-Force]
 [-Timeout <Int32>] [-Encoding <Encoding>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

SessionIdIndexedTyped

Read-TcValue -SessionId <Int32[]> [-IndexGroup] <UInt32> [[-IndexOffset] <UInt32>] [-ValueType] <Type>
 [[-Size] <Int32>] [-Force] [-Timeout <Int32>] [-Encoding <Encoding>] [-ProgressAction <ActionPreference>]
 [<CommonParameters>]

SessionIdSymbol

Read-TcValue -SessionId <Int32[]> [-Path] <String> [-Extended] [-Force] [-Timeout <Int32>]
 [-Encoding <Encoding>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

InputObject

Read-TcValue [-InputObject] <ISymbol> [-Force] [-Timeout <Int32>] [-Encoding <Encoding>]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

This Cmdlet read values from TwinCAT Devices.

The devices can be accessed via different ValueProviders.

EXAMPLES

EXAMPLE 1

PS> $session = New-TcSession -NetId '1.2.3.4.5.6' -Port 851
PS> $symbol = $session | get-TcSymbol -Path 'TwinCAT_SystemInfoVarList._AppInfo.ProjectName'
PS> $symbol | Read-TcValue

ADS_DynSymbols

Create an ADS Session/Connection, determine the 'ProjectName' Symbol from the running PLC Project, read the current value of the symbol and print it to the console.

EXAMPLE 2

PS> Read-TcValue -IndexGroup 0x4040 -IndexOffset 0x1247a8 -NetId 172.17.62.105.1.1 -port 851 -size 0xff | format-hex


           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  ................
00000040   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000050   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000060   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000070   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000080   11 00 01 01 A0 86 01 00 14 00 5E 01 21 C2 15 00  .... ?....^.!A..
00000090   00 7F F1 57 3B 83 6C 07 1E 00 00 00 00 00 00 00  .⌂ñW;?l.........
000000A0   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000000B0   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000000C0   41 44 53 5F 44 79 6E 53 79 6D 62 6F 6C 73 5F 50  ADS_DynSymbols_P
000000D0   6C 63 54 61 73 6B 00 00 00 00 00 00 00 00 00 00  lcTask..........
000000E0   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000000F0   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ...............

Reads 256 Bytes via IndexGroup/IndexOffset from the specified target system and prints the out formatted as hexdump.

EXAMPLE 3

PS> Read-TcValue -session $session -IndexGroup 0x4040 -IndexOffset 0x1247A8 -ValueType String
ADS_DynSymbols

Reads a string typed value from IndexGroup / IndexOffset.

In this example the ProjectName of the running PLC Project resides at that ProcessImage Address.

EXAMPLE 4

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).

PARAMETERS

-NetId

The NetId part of the AmsAddress for the value read.

Type: AmsNetId[]
Parameter Sets: NetIdPortSymbol, NetIdPortIndexed, NetIdPortIndexedTyped
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Route

Specifies the target system(s) to read value from.

Type: IRoute[]
Parameter Sets: RouteIndexed, RouteIndexedTyped, RouteSymbol
Aliases: Destination

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Address

The Address(es) of the system(s) where to read the value.

The Address can consist of NetId, IPAddress or HostName.

Wildcards are permitted.

Type: String[]
Parameter Sets: AddressIndexed, AddressIndexedTyped, AddressSymbol
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Session

The Session to use for the value read.

Type: ISession[]
Parameter Sets: SessionIndexed, SessionIndexedTyped, SessionSymbol
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-SessionId

Specifies the Session (with unique ID) to use for the value read.

Type: Int32[]
Parameter Sets: SessionIdIndexed, SessionIdIndexedTyped, SessionIdSymbol
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Port

The address Port to use for the value read.

Type: Int32
Parameter Sets: NetIdPortSymbol, NetIdPortIndexed, NetIdPortIndexedTyped, RouteIndexed, RouteIndexedTyped, RouteSymbol, AddressIndexed, AddressIndexedTyped, AddressSymbol
Aliases:

Required: True
Position: Named
Default value: 10000
Accept pipeline input: False
Accept wildcard characters: False

-IndexGroup

The IndexGroup of the Symbol to read from target system.

Only for IndexGroup/IndexOffset access.

Type: UInt32
Parameter Sets: NetIdPortIndexed, NetIdPortIndexedTyped, RouteIndexed, RouteIndexedTyped, AddressIndexed, AddressIndexedTyped, SessionIndexed, SessionIndexedTyped, SessionIdIndexed, SessionIdIndexedTyped
Aliases: IG

Required: True
Position: 1
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-IndexOffset

The IndexOffset of the Symbol to read from the target system.

Only for IndexGroup/IndexOffset access.

Type: UInt32
Parameter Sets: NetIdPortIndexed, NetIdPortIndexedTyped, RouteIndexed, RouteIndexedTyped, AddressIndexed, AddressIndexedTyped, SessionIndexed, SessionIndexedTyped, SessionIdIndexed, SessionIdIndexedTyped
Aliases: IO

Required: False
Position: 2
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-ValueType

The dataType of the Value for a 'ReadAny' access.

Only usable with IndexGroup/IndexOffset access.

Type: Type
Parameter Sets: NetIdPortIndexedTyped, RouteIndexedTyped, AddressIndexedTyped, SessionIndexedTyped, SessionIdIndexedTyped
Aliases: Type, ReadType

Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Size

The 'Size' of Value (in bytes) to read.

Type: Int32
Parameter Sets: NetIdPortIndexed, NetIdPortIndexedTyped, RouteIndexed, AddressIndexed, SessionIndexed, SessionIdIndexed
Aliases: ReadSize, Length

Required: True
Position: 3
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False
Type: Int32
Parameter Sets: RouteIndexedTyped, AddressIndexedTyped, SessionIndexedTyped, SessionIdIndexedTyped
Aliases: ReadSize, Length

Required: False
Position: 3
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False

-Path

The instance path of the symbol to read (symbolic access).

This parameter supports wildcards.

Type: String
Parameter Sets: NetIdPortSymbol, RouteSymbol, AddressSymbol, SessionSymbol, SessionIdSymbol
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-InputObject

The symbol object to read value from.

Type: ISymbol
Parameter Sets: InputObject
Aliases: Symbol

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Extended

Switch on 'ExtendedMode', what means that primitive values are not resolved to their primitive managed (powershell) counterparts, but still contain rich metadata as DynamicValues.

Type: SwitchParameter
Parameter Sets: NetIdPortSymbol, RouteSymbol, AddressSymbol, SessionSymbol, SessionIdSymbol
Aliases: FullMetadata

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Force

Force reading value.

This flag bypasses the FailFastInterceptor to retry communication in every case.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Timeout

The communication ADS timeout in milliseconds.

A value of 0 disables the timeout.

A value \<= 0 sets the Default (5000 ms).

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False

-Encoding

Specifies the Encoding for strings.

The DefaultEncoding is ANSI with actual code page.

Type: Encoding
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: System.Text.UTF8Encoding+UTF8EncodingSealed
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

TwinCAT.ISession[]

The Session to use for the value read.

TwinCAT.TypeSystem.ISymbol

The symbol object to read value from.

OUTPUTS

NOTES