Note
To see an example of Multiple-Release, see the Initialize method.
public static TPCANStatus Uninitialize(
ushort Channel
)
Public Shared Function Uninitialize (
Channel As UShort
) As TPCANStatus
public:
static TPCANStatus Uninitialize(
unsigned short Channel
)
The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:
A PCAN Channel can be released using one of this possibilities:
Transmit queue on uninitialize: When a connection is terminated, the underlying hardware's transmit-queue will not be immediately discarded. The API will wait some time before terminating, so that the hardware has time to send (or try to send) the unsent messages. When the timer runs out (about 500 milliseconds), the rest of the messages in the queue (if any) are discarded.
The following example shows the initialization and uninitialization (Single-Release) processes for the channel PCAN_PCIBUS1. In case of failure, the returned code will be translated to a text (according with the operating system language) in English, German, Italian, French or Spanish, and it will be shown to the user.
TPCANStatus result;
System.Text.StringBuilder strMsg;
strMsg = new System.Text.StringBuilder(256);
// The Plug & Play Channel (PCAN-PCI) is initialized
//
result = PCANBasic.Initialize(PCANBasic.PCAN_PCIBUS1, TPCANBaudrate.PCAN_BAUD_500K);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error and show it
//
PCANBasic.GetErrorText(result, 0, strMsg);
Console.WriteLine(strMsg.ToString());
}
else
Console.WriteLine("PCAN-PCI (Ch-1) was initialized");
// .... do communication ...
// The PCI Channel is released
//
result = PCANBasic.Uninitialize(PCANBasic.PCAN_PCIBUS1);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error and show it
//
PCANBasic.GetErrorText(result, 0, strMsg);
Console.WriteLine(strMsg.ToString());
}
else
Console.WriteLine("PCAN-PCI (Ch-1) was released");
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
strMsg = New System.Text.StringBuilder(256)
' The Plug & Play Channel (PCAN-PCI) is initialized
'
result = PCANBasic.Initialize(PCANBasic.PCAN_PCIBUS1, TPCANBaudrate.PCAN_BAUD_500K)
If result <> TPCANStatus.PCAN_ERROR_OK Then
' An error occurred, get a text describing the error and show it
'
PCANBasic.GetErrorText(result, 0, strMsg)
Console.WriteLine(strMsg.ToString)
Else
Console.WriteLine("PCAN-PCI (Ch-1) was initialized")
End If
' .... do communication ...
' The PCI Channel is released
'
result = PCANBasic.Uninitialize(PCANBasic.PCAN_PCIBUS1)
If result <> TPCANStatus.PCAN_ERROR_OK Then
' An error occurred, get a text describing the error and show it
'
PCANBasic.GetErrorText(result, 0, strMsg)
Console.WriteLine(strMsg.ToString)
Else
Console.WriteLine("PCAN-PCI (Ch-1) was released")
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
strMsg = gcnew System::Text::StringBuilder(256);
// The Plug & Play Channel (PCAN-PCI) is initialized
//
result = PCANBasic::Initialize(PCANBasic::PCAN_PCIBUS1, TPCANBaudrate::PCAN_BAUD_500K);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error and show it
//
PCANBasic::GetErrorText(result, 0, strMsg);
Console::WriteLine(strMsg->ToString());
}
else
Console::WriteLine("PCAN-PCI (Ch-1) was initialized");
//.... do communication ...
// The PCI Channel is released
//
result = PCANBasic::Uninitialize(PCANBasic::PCAN_PCIBUS1);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error and show it
//
PCANBasic::GetErrorText(result, 0, strMsg);
Console::WriteLine(strMsg->ToString());
}
else
Console::WriteLine("PCAN-PCI (Ch-1) was released");