CanGetErrorString
関数を使用することで、全ての関数についてそのエラーコードを文字列に変換することができます。
CanGetErrorString 関数で使用する文字列は、最大256バイトです。
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('sjis')}" )
Ret.value = ccan.CanExit ( Id )
ErrorRet.value = ccan.CanGetErrorString( Ret, ErrorString )
print( f"CanExit : {ErrorString.value.decode('sjis')}" )