Init and Exit Processing

Init and exit processing are common processing that are necessary for all programming.
Init processing is performed by function CanInit.
This function creates the driver file and allocates the necessary memory.

There are 2 parameters in function CanInit.
The first parameter is DeviceName.
DeviceName is a character string such as "CAN000" which is registered in Device Manager or the utility.

The second parameter is ID.
ID is a number passed from driver, and this ID is required to use the following functions.

If function terminates normally, the return value (Ret) is 0.
If function execution failed, a value other than 0 is returned.

Exit processing is performed by function CanExit.
This function stops device and driver operations and releases all used resources such as memory and threads.
Please make sure to execute this function before terminating application.
Otherwise, resources used by the driver may remain unreleased.

 

Programming Example for each language

Perform the init and exit processing for device "CAN000"

 

Visual Basic .NET

Dim Ret As Integer

Dim Id As Short

 

Ret = CanInit( "CAN000" , Id )
If Ret <> 0 Then
    System.Diagnostics.Debug.WriteLine("Error occurred in CanInit " & Ret)
End If

 

Ret = CanExit( Id )
If Ret <> 0 Then
    System.Diagnostics.Debug.WriteLine("Error occurred in CanExit " & Ret)
End If

 

Visual C#

int Ret;
short Id;

 

Ret = can.Init ( "CAN000" , out Id );
if(Ret != 0){

    System.Diagnostics.Debug.WriteLine("Error occurred in CanInit " + Ret.ToString());
}

 

Ret = can.Exit ( Id );
if(Ret != 0){
    System.Diagnostics.Debug.WriteLine("Error occurred in CanExit " + Ret.ToString());

}

 

Visual C++ (MFC)

long Ret;
short Id;

 

Ret = CanInit( "CAN000" , &Id );
if(Ret != 0){
   printf("Error occurred in CanInit %d\n", Ret);
}

 

Ret = CanExit( Id );
if(Ret != 0){
   printf("Error occurred in CanExit %d\n", Ret);
}