If you don't want exceptions raised, there is a property for that, RaiseExcept, just set it to false:
{:If @true, communication errors raise exceptions. If @false (default), only
the @link(LastError) value is set.}
property RaiseExcept: boolean read FRaiseExcept write FRaiseExcept;
procedure TBlockSerial.ExceptCheck;
var
e: ESynaSerError;
s: string;
begin
if FRaiseExcept and (FLastError <> sOK) then
begin
s := GetErrorDesc(FLastError);
e := ESynaSerError.CreateFmt('Communication error %d: %s', [FLastError, s]);
e.ErrorCode := FLastError;
e.ErrorMessage := s;
raise e;
end;
end;
The other possibility is to catch the exception and handle the error properly.
As for the other part of the problem, waiting for CR/LF. it happens if you use RecvTerminated
{:This method waits until a terminated data string is received. This string
is terminated by the Terminator string. The resulting string is returned
without this termination string! If no data is received within the Timeout
(in milliseconds) period, @link(LastError) is set to @link(ErrTimeout).}
function RecvTerminated(Timeout: Integer; const Terminator: AnsiString): AnsiString; virtual;
or if you use any of the methods that rely on RecvTerminated:
RecvString, ATCommand, ATConnect. For instance:
function TBlockSerial.RecvString(Timeout: Integer): AnsiString;
var
s: AnsiString;
begin
Result := '';
s := RecvTerminated(Timeout, #13 + #10);
if FLastError = sOK then
Result := s;
end;