Delphi serial port Comport data

1.7k Views Asked by At

I have an application that listens on a serial port. It uses TComPort to connect to the serial port, and a timer to listen. Basically, all we're doing is listening for data, specifically barcodes. However, we seem to have a problem. The data "comes across" in the form #0#0#0#0.... when a barcode is scanned.

The code is as follows:

if Comport2.Active then
begin
  sStr := Comport2.ReadAnsiString;
  if Length(sStr) <> 0 then
  begin
    MatCodeEdit.Text := '';
    MatCodeEdit.Text := sStr;
  end;
end;

The serial port is connected with the following parameters:

Comport2.DataBits := db8;
Comport2.Parity := paNone;
Comport2.StopBits := sb1;

No errors occur on connection. The above code has, actually, succeeded in reading the contents of the serial port transmission. But, currently seems only to receive the #0#0#0... string.

Does anyone have any ideas about this?

0

There are 0 best solutions below