Init and Exit Processing

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

There are 2 parameters in function CntInit.
The first parameter is DeviceName.
DeviceName is a character string such as "CNT000" 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 CntExit.
This function stops the device and driver operation, releases all the resources used by memory and threads, etc.
Please make sure to execute this function before terminating application.
Otherwise, the resources used by driver may remain unopened.

 

Programming Example for each language

Perform the init and exit processing for device "CNT000"

Visual Basic .NET

Dim Ret As Integer
Dim Id As Short

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

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

Visual C#

int Ret;
short Id;

Ret = cnt.Init ( "CNT000" , out Id );
if(Ret != 0){
    System.Diagnostics.Debug.WriteLine("Error occurred in CntInit " + Ret.ToString());
}

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

Visual C++ (MFC)

long Ret;
short Id;

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

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

Python

Ret = ctypes.c_long()

Id = ctypes.c_short()

 

Ret.value = ccnt.CntInit ( b"CNT000" , ctypes.byref(Id))

if Ret.value != 0:

    print(f"Error occurred in CntInit {Ret.value}\n")

 

Ret.value = ccnt.CntExit ( Id )

if Ret.value != 0:

    print(f"Error occurred in CntExit {Ret.value}\n")