Get Error Contents

By using function CanGetErrorString , it is possible to convert error code to a character string for all functions.
The string used with the CanGetErrorString function can be up to 256 bytes.

 

Programming Example in Visual Basic .NET

Dim Ret As Integer
Dim ErrorRet As Integer
Dim Id As Short
Dim ErrorString As New StringBuilder("", 256)

 

Ret = CanInit( "CAN000" , Id )
ErrorRet = CanGetErrorString( Ret, ErrorString )
System.Diagnostics.Debug.WriteLine( "CanInit: " & ErrorString )

 

Ret = CanExit( Id )
ErrorRet = CanGetErrorString( Ret , ErrorString )
System.Diagnostics.Debug.WriteLine( "CanExit: " & ErrorString )

 

Programming Example in Visual C#

int Ret;
int ErrorRet;

short Id;

string ErrorString;

 

Ret = can.Init( "CAN000", out Id );

ErrorRet = can.GetErrorString( Ret , ErrorString );
System.Diagnostics.Debug.WriteLine( "CanInit: " + ErrorString );

 

Ret = can.Exit( Id );
ErrorRet = can.GetErrorString( Ret , ErrorString );
System.Diagnostics.Debug.WriteLine( "CanExit: " + ErrorString );

 

Programming Example in Visual C++ (MFC)

long Ret;
long ErrorRet;
short Id;
char ErrorString[256];

 

Ret = CanInit( "CAN000" , &Id );
ErrorRet = CanGetErrorString( Ret , ErrorString );
printf("CanInit: %s", ErrorString );

 

Ret = CanExit( Id );
ErrorRet = CanGetErrorString( Ret , ErrorString );
printf("CanExit: %s", ErrorString );