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.
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
)
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
);
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 );
Ret = ctypes.c_long()
ErrorRet = ctypes.c_long()
Id = ctypes.c_short()
ErrorString = ctypes.create_string_buffer(256)
Ret.value = ccan.CanInit ( b"CAN000" , ctypes.byref(Id) )
ErrorRet.value = ccan.CanGetErrorString( Ret, ErrorString )
print( f"CanInit : {ErrorString.value.decode('utf-8')}" )
Ret.value = ccan.CanExit ( Id )
ErrorRet.value = ccan.CanGetErrorString( Ret, ErrorString )
print( f"CanExit : {ErrorString.value.decode('utf-8')}" )