IpAddress

This parameter applies only to hardware of type PcanLan. It is used to distinguish between 2 or more hardware of this kind connected to a computer simultaneously. An IP address represents the configured network address on a PCAN-Gateway device, i.e., the address used to communicate with a PCAN-Gateway device through the network (LAN/WAN).

The IP address identifies a device effectively because it is not allowed to have the same IP address twice within a network, at the same time (address conflict).

This parameter can be used when it is needed to differentiate between PCAN-Gateway devices connected to the same system at a given time, or just to get more information about a remote PCAN-Gateway device through its IP address.

Availability

Available since PCAN-Basic version 4.0.0.

It can be read without initialization since version 4.6.1.

Supported By

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

Since the format used for the IP address is IPv4, possible values are string representing 4 number sections separated by ‘.’, which are in the range [0…255]. Example of an IP address is: “192.168.0.1”.

Default Value

Does not apply.

Initialization Status

Get: It can be read on initialized or uninitialized PCAN Channels.

Example

The following code shows how to retrieve the IP address of a LAN Channel. The BitrateAdapting parameter is used to facilitate the connection to any available PCAN-LAN Channel:

C#
PcanChannel[] channelsToCheck = { PcanChannel.Lan01, PcanChannel.Lan02, PcanChannel.Lan03 };
string ipAddress;

for (int i = 0; i < 3; i++)
{
    if (Api.SetValue(channelsToCheck[i], PcanParameter.BitrateAdapting, ParameterValue.Activation.On) == PcanStatus.OK)
    {
        PcanStatus result = Api.Initialize(channelsToCheck[i], Bitrate.Pcan500);
        if ((result == PcanStatus.OK) || (result == PcanStatus.Caution))
        {
            if (Api.GetValue(channelsToCheck[i], PcanParameter.IpAddress, out ipAddress) == PcanStatus.OK)
            {
                Console.WriteLine($"Associated IP address of {channelsToCheck[i]}: {ipAddress}");
            }
            Api.Uninitialize(channelsToCheck[i]);
        }
        else
            Console.WriteLine($"Error while trying to initialize the Channel {channelsToCheck[i]}");
    }
    else
        Console.WriteLine($"Error while trying to activate the parameter BitrateAdapting for the {channelsToCheck[i]}");
}

See Also