Hardware Delphi

Title: How to find out if the RS232 has data in the receive buffer
Question: Sometimes its important to find out if the serial device has data waiting ...
Answer:
With the function ClearCommError its possible to find out how many bytes of data are in the receive buffer (and send buffer) of the serial interface.
procedure DataInBuffer(Handle: THandle;
var InQueue, OutQueue: integer);
var ComStat: TComStat;
e: integer;
begin
if ClearCommError(Handle, e, @ComStat) then
begin
InQueue := ComStat.cbInQue;
OutQueue := ComStat.cbOutQue;
end
else
begin
InQueue := 0;
OutQueue := 0;
end;
end;