"Error reading modem state (5) , Acces refusé"

hi,


This error appears when i disconnect myself usb cable for test.
Is it possible to detect hardware disconnect by TVaComm Events ?

You should get an OnError event upon disconnect.
There is no separate event for a disconnect as the underlying Windows serial communications API doesn't offer this and in pure RS232 hardware there is no such trigger.

Sorry, but in version 1.5.2, OnError events never upon.

Look on source code, on :
procedure TVaCustomComm.Error(Msg: string);
var
  ErrorCode: Integer;
begin
  ErrorCode := GetLastError;
  raise EVaCommError.CreateFmt(Msg, [ErrorCode,
    SysErrorMessage(ErrorCode)]);
end;

missing line "FOnError(Self, ErrorCode);"
 No ?

I've changed it by :


procedure TVaCustomComm.Error(Msg: string);
var
  ErrorCode: Integer;
begin
  ErrorCode := GetLastError;
  if Assigned(FOnError) then
    FOnError(Self, ErrorCode)
  else
  raise EVaCommError.CreateFmt(Msg, [ErrorCode,
    SysErrorMessage(ErrorCode)]);
end;

Is it Good ?

The Error() method is not related to communication errors but things like error in opening a COM port.
OnError is triggered from ClearLineErrors() that is called from HandleLineEvent() when the error bit is set in the status flags of the UART