ApiGetHandleInformation Method

Retrieves information about device type and channel number from a PCAN Handle

Definition

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
C#
public static PcanStatus GetHandleInformation(
	PcanChannel handle,
	out PcanDevice device,
	out int channel
)

Parameters

handle  PcanChannel
The handle of a PCAN Channel
device  PcanDevice
Output variable to store the device type
channel  Int32
Output variable to store the channel number

Return Value

PcanStatus

The return value is a PcanStatus value. OK is returned on success. The typical errors in case of failure are:

Example

The following example shows the use of the GetHandleInformation method to retrieve the PCAN device name and channel number associated to the given channel.

C#
// The information about the handle is retrieved
//
PcanStatus result = Api.GetHandleInformation(PcanChannel.Lan07, out var device, out var channelNumber);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);                
}
else
{
    // The information about the handle is shown
    //
    Console.WriteLine($"The given {nameof(PcanChannel)} represents the {device} hardware number {channelNumber}.");
}

Exceptions

DllNotFoundExceptionThe underlying PCANBasic.dll library could not be found.

See Also