-
Forgot to say I am using Delphi 2010 (unicode of course). I will test the advice from dygj and I return results here.
Thanks.
2010-01-05 15:17:37 UTC by yapt
-
Set Stopstring in code
OnComportOpen;
begin
Mypacket.stopstring:=#10
end;.
2010-01-05 14:33:52 UTC by dygj
-
Hello,
I am trying to read a barcode from a COM1. I have put a: - Form - TComPort - TComDataPacket
Barcode are EAN13, but the first barcode is always 8 characters/bytes and all goes wrong on nexts reads.
To solve it I have linked ComPort1 with ComDataPacket1, set StopString to #$D (CR character I think). But no OnPacket event is launched.
I have debug CPort source code until this...
2010-01-04 18:41:51 UTC by yapt
-
Same here.
Any **simple** example ?
Thanks.
2009-12-27 21:39:05 UTC by yapt
-
Values in my example are exchanged:
Upper(FStopString) value is: #$D
Upper(Copy(Buffer, Len + 1, Length(Buffer) - Len)): '7638900271942'#$D'76389002'
But the question is the same.
2009-12-27 17:19:24 UTC by yapt
-
Hello,
I am trying to read a barcode from a COM1. I have put a:
- Form
- TComPort
- TComDataPacket
I have linked ComPort1 with ComDataPacket1, set StopString to #$D (CR character). But no OnPacket event is launched.
I have debug CPort source code until this line (3531 line number):
Found := Pos(Upper(FStopString),
Upper(Copy(Buffer, Len + 1, Length(Buffer) -...
2009-12-27 17:15:51 UTC by yapt
-
I am testing it with a Metrologic USB (COMx emulated) barcode reader and With Delphi 2010.
But I have starting now to use this component and perhaps I cannot help what I would like to.
Greetings.
2009-12-27 14:00:13 UTC by yapt
-
Ok.
I've tried the following code with a device sending the string '128' and the char for endofline:
procedure TForm1.ComDataPacket1Packet(Sender: TObject; const Str: string);
var
msg: pansichar;
begin
//sleep(1000);
msg:=PAnsiChar(Str);
Memo1.Lines.Add(ansistring(msg));
//Memo1.Lines.Add('......');
end;
and the memo result was this:
Memo1
128
128...
2009-12-14 21:55:38 UTC by sumerset
-
Do NOT use ShortString unless you are sure you won't hit the length limit on ShortString.
AnsiString and Bytes types are safe, byte size, and have no length limit.
2009-12-14 16:09:06 UTC by wpostma
-
I had a rough time making it work also. I also believe it is due to the way Delphi 2010 uses strings. Read your compiler warnings that are on the bottom of the Delphi IDE. These will tell you every one of the variables that need to be changed to ansistring or ansichar. Also use shortstring instead of string wherever you can if you can. These seemed to solve the problem for me. Also Which...
2009-12-14 16:07:35 UTC by pvandermyde