CAN_Uninitialize

PCAN-Basic

PCAN-Basic Documentation
Home
PreviousUpNext
CAN_Uninitialize

Uninitializes a PCAN Channel.

Syntax
TPCANStatus __stdcall CAN_Uninitialize(
        TPCANHandle Channel
);
Parameters 
Description 
Channel 
The handle of a PCAN Channel (see TPCANHandle). 

The return value is a TPCANStatus code. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

PCAN_ERROR_INITIALIZE: 
Indicates that the given PCAN channel cannot be uninitialized because it was not found in the list of reserved channels of the calling application. 

A PCAN Channel can be released using one of this possibilities: 

Single-Release: Given a handle of a PCAN Channel initialized before with CAN_Initialize. If the given channel can not be found then an error is returned. 

Multiple-Release: Giving the handle value PCAN_NONEBUS which instructs the API to search for all channels initialized by the calling application and release them all. This option cause no errors if no hardware were uninitialized. 

Transmit-queue at uninitialize: When a PCAN-Basic channel connection is terminated, the underlying hardware's transmit-queue will not immediately be discarded. PCAN-Basic will wait some time before finalizing, so that the hardware has time to send (or try to send) those unsent messages. When the time is up (amount 500 milliseconds), the rest of the messages in the queue (if any) are discarded. 

The following example shows the initialize and uninitialize (Single-Release) processes for the PCAN_PCIBUS1 channel. 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. 

Note: To see an example of Multiple-Release, see the CAN_Initialize function. 

C++:  

TPCANStatus result;
char strMsg[256];

// The PCI Channel is initialized
//
result = CAN_Initialize(PCAN_PCIBUS1,PCAN_BAUD_500K);
if(result != PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    CAN_GetErrorText(result, 0, strMsg);
    MessageBox(strMsg);
}
else
    MessageBox("PCAN-PCI (Ch-1) was initialized");

....

// The PCI Channel is released
//
result = CAN_Uninitialize(PCAN_PCIBUS1);
if(result != PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    CAN_GetErrorText(result, 0, strMsg);
    MessageBox(strMsg);
}
else
    MessageBox("PCAN-PCI (Ch-1) was released");

CAN_Initialize 

 

Class-method Version: Uninitialize

Copyright © 2017. PEAK-System Technik GmbH. All rights reserved.
Send feedback to this documentation