// Send data procedure senddata (astr: string); VAR K: Integer; P: Pchar; ACHR: Array of Char; Begin SetLength; SETLENGTH (Achr, Length (astr)); P: = pChar (astr); fork: = 0 to length (astr) -1 do begin Achr [k]: = p ^; sbuf [k]: = ORD (ACHR [K]); P: = P 1; End; if frmmain.mscomm1.Portopen = true kilin frmmain.mscomm1.output: = sbuf; end; sleep (200); end; this is a code for sending strings, if you send a hexadecimal, use an array directly Of Byte, it's more simple, receives a similar. // receive data procedure tfrmmain.mscomm1comm (sender: TOBJECT); var V: Olevariant; astr: string; in_Array: array of byte; xtemp: olevariant; xscr: array of byte; I, J: Integer; xnnak, xnrsd: integer; begin i: = mscomm1.inbuffercount;
IF i = 0 THEN EXIT;
IF mscomm1.commmevent = 2 dam xtemp: = mscomm1.input; setLength (XSCR, I);
XSCR: = xTemp;
For j: = 0 to i-1 do xrecdata: = XRecdata char (XSCR [J]);
LSTDISPLAY.ITEMS.Add (FormatorTime ('hh: mm: ss', now) ':' xrecdata; lstdisplay.Items.add (''); end;