hello,
i will not add your ComportisBusy in LazSerial Component because when you can't access to a serial device, you can have other reasons :
1 - Already in use
2 - Doesn't exist
3 - Hardware Malfunction
4 - Bad parameters
Then you must manage exception on serial device access.
if i write this in my sertest example for the code of the open button :
procedure TFMain.BOpenClick(Sender: TObject);
begin
Serial.Device := EditDevice.Text;
try
Serial.Open;
except
On E :Exception do begin
Memo.Lines.Add(E.ClassName + ' : ' + E.Message);
end;
end;
end;
when exception comes , i have no exception window (see Attachment). To avoid exception window while you are debugging , add the exception in
Tools/Options/Debugger/Language Exceptions and check the exception (ignore these exceptions) See Attachment.
If you don't want to manage exception , you can do this :
Serial.Synser.Connect(Serial.Device);
If Serial.SynSer.Handle = THandle(-1) then
begin
Memo.Lines.Add(Serial.Device + ' is busy');
exit;
end
else Serial.Close;
Friendly, J.P