A ver, Egostar me corrige si me equivoco, hice algunos añadidos al ultimo codigo que mado PepePancho:
Código Delphi
[-]
var
Form1: TForm1;
Cuantos, CuentaB : Integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
if not ComPort.Connected then
ComPort.Open;
comport.WriteStr(#2#0);
end;
procedure TForm1.ComPortRxChar(Sender: TObject; Count: Integer);
var
Str: String;
begin
ComPort.ReadStr(Str, Count);
if length(Str)>= 8 then
ShowMessage('OK')
else if Str = #1 then begin
case Cuantos of
1: begin
ComPort.WriteStr(#2#2);
Cuantos := 2;
end;
2: begin ComPort.WriteStr(#2#3);
Cuantos := 3;
end;
3: begin showmessage('Chip Borrado.. OK!')
end;
end
else if Str = #2 then begin
case Cuantos of
1: begin
end;
2: begin ComPort.WriteStr(Buffer[CuentaB]);
Inc(CuentaB);
end;
end;
else if Str = #53 then begin
case Cuantos of
2: ProcedimientoEscribir;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if not ComPort.Connected then
ComPort.Open;
comport.WriteStr(#4#1#0#1);
Cuantos := 1;
end;
procedure TForm1.ProcedimientoEscribir;
begin
if CuentaB <= Length(Buffer) then
begin
ComPort.WriteStr(Buffer[CuentaB]);
Inc(CuentaB);
end
else
ComPort.WriteStr(ByteFinTx);
end;
end.