CAN_Reset

PCAN-Basic

PCAN-Basic Documentation
Home
PreviousUpNext
CAN_Reset

Resets the receive and transmit queues of a PCAN Channel.

Syntax
TPCANStatus __stdcall CAN_Reset(
        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 was not found in the list of initialized channels of the calling application. 

Calling this function ONLY clear the queues of a Channel. A reset of the CAN controller doesn't take place. 

Normally a reset of the CAN Controller is desired when a bus-off occur. In this case an application cannot use the channel to communicate anymore, until the CAN controller is reset. Consider using the PCAN-Basic parameter PCAN_BUSOFF_AUTORESET which instructs the API to automatically reset the CAN controller when a bus-off state is detected. 

Another way to reset errors like bus-off, bus-heavy and bus-light, is to uninitialize and initialize again the channel used. This causes a hardware reset, but only when no more clients are connected to that channel.

The following example shows the use of CAN_Reset on 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. 

Note: It is assumed that the channel was already initialized. 

C++:  

TPCANStatus result;
char strMsg[256];

// The PCI Channel is reset
//
result = CAN_Reset(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 reset");

CAN_Read 

CAN_Write 

CAN_SetValue 

 

Class-method Version: Reset

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