Ver Mensaje Individual
  #10  
Antiguo 30-03-2008
JoseFco JoseFco is offline
Baneado
 
Registrado: dic 2007
Posts: 1.861
Reputación: 0
JoseFco cantidad desconocida en este momento
Cita:
Empezado por FGarcia Ver Mensaje
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;  //OJO AQUI SE MODIFICO
 
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 //Modo Escribir
        ComPort.WriteStr(#2#3);
        //ProcedimientoEscribir
        Cuantos := 3;
      end;
   3: begin //Modo Borrar
         //ProcedimientoBorrar
         showmessage('Chip Borrado.. OK!')
      end;
   end
 
//AQUI la cadena recibida vale 2
 else if Str = #2 then begin
   case Cuantos of
      1: begin
          //
          end;
      2: begin //Envia el primer byte. CuentaB vale 0.
             ComPort.WriteStr(Buffer[CuentaB]);
             Inc(CuentaB);
          end;
 
   end;
 
//AQUI el chip respondio a el envio del primer byte
 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;
 
{Este procedimiento pretende escribir caracter a caracter sobre el
puerto serie. CuentaB es un contador que lleva el registro de las transmisiones efectuadas, siempre se 
compara su valor contra el valor de la longitud del buffer que contiene el archivo a transmitir.}
 
procedure TForm1.ProcedimientoEscribir;
begin
  if CuentaB <= Length(Buffer) then
    begin
      ComPort.WriteStr(Buffer[CuentaB]);
      Inc(CuentaB);
    end
  else
    ComPort.WriteStr(ByteFinTx);
end;
end.

Hola Fgarcia. Ya le di mil vueltas a este codigo y no hay forma de que copile.

Un Saludo.
Responder Con Cita