Delphi 7 Serial Port Example
I'm trying to reading a simple string from host on Serial line RS232. The parameters of receive - transmission are the same for both: Baudrate: 9600; Data: 8bit; Parity: None; Stop: 1bit; Flow Control: None; I've tried to send this string:!A243B324C213D300# I use '!' And '#' as header and finish to be sure the string will be received at all. The problem is that I can receive the string until the 15th character (3).
I know this because if I use this code: procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer); begin ComPort1.ReadStr(Str, Count); memo1.Lines.Add(str); end; I will see!A243B324C213D3 00# I've tried to extend the buffer of the comport, without results. So why I can't receive the complete string in one shot? I found this library here and it works fine until now. With TComPort component comes another one: TComDataPacket.


Torry's Delphi Pages. Numerous new methods and events to control serial port state changes. Microsoft Outlook Error Message Not Enough Memory Error there. Includes examples for.
Simply connect this to TComPort, setup StartString and StopString properties and use event onPacket to get complete data. ComDataPacket1.Comport:= Comport1; ComDataPacket1.StartString:= '!' ; ComDataPacket1.StopString:= '#'; ComDataPacket1.onPacket:= ComDataPacket1Packet. //this is real code from one of my applications where I use it for barcode reader service procedure TDM.ComDataPacket1Packet(Sender: TObject; const Str: string); begin BarCodeReader.Barcode:= Str; end.
'Philip' wrote. >function TForm1.ReceivePacket(): String; >//Dumps receive buffer to string >var >d: array[1.80] of Char; >s: String; >BytesRead: Cardinal; >i: Integer; >begin >s:= '; >if ReadFile (ComFile, d, sizeof(d), BytesRead, Nil) then >for i:= 1 to BytesRead do s:= s + d[i]; >Result:= s; >end;. >Any help would be appreciated. Philip, I suggest using a COM-port component like Dejan Crnila's TComport from Then you can read and accumulate the characters as they come in inside an OnRxChar event handler. Then from you button event handler, you can fetch the accumulated characters and empth the array. Papa Roach Infest Zip. HTH, JohnH Philip 08.05.08 13:15. 'Philip' wrote in message news:48235f15$1@newsgroups.borland.com.