Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Cuantos ComPortRxChar? (https://www.clubdelphi.com/foros/showthread.php?t=54671)

JoseFco 01-04-2008 03:39:51

Creo que la cosa es mas complicadita todavia.;)

Por ejemplo si te fijas en el codigo del programita.Yo para que por el serial port me mande un 10 tengo que escribir un #16 .

A mi me recomendaron usar el buffer, para no tener que convertir otra vez el file.creo que eso me lo dijo seoane, en otro hilo.Pero la rutina con el buffer se complico.

Un Saludo.

egostar 01-04-2008 04:17:39

Vamos a hacer una chapuza :D:D:D

Código Delphi [-]
    5: begin // Comando para escribir el chip(06 04 00 00 10 00)
           ComPort.WriteStr(#6#4#0#0#16#0);
           sleep(100);
           Count := 0; //Agregar esta variable Integer
           LineaMemo := Memo1.Lines[Count]; //Agregar esta variable String (LineaMemo)
           ComPort.WriteStr(Char(strtoint('$'+Copy(LineaMemo,1,2))));
           Delete(LineaMemo,1,3);
           Contador := 2;
     end;
//........
     else if Str = #83 then begin //83 decimal
              sleep(100);
              ComPort.WriteStr(Char(strtoint('$'+Copy(LineaMemo,1,2))));
              Delete(LineaMemo,1,3);
              if LineaMemo = '' then begin
                 LineaMemo := Memo1.Lines[Count+1];
              end;
              Inc(Contador);
           end;

Espero te funcione como espero :)

Salud OS

JoseFco 01-04-2008 04:20:30

Hola egostar.

Resuelto el problema de que no mandara el file del memo completo:
jajajajajajaja yo solo estaba recibiendo 01 del chip y comparando.
Entonces si yo estoy recibiendo 53 y me pongo a leer 53 estoy perdido por eso se detenia la rutina. cambie y lo puse a esperar 83 Dec = a 53 hex.:p
Ese era el problema, ahora hay que ver lo de mandar lo que esta en el memo que lo cambia todo.

Un Saludo.

egostar 01-04-2008 04:23:52

Cita:

Empezado por JoseFco (Mensaje 276601)
Hola egostar.

Resuelto el problema de que no mandara el file del memo completo:
jajajajajajaja yo solo estaba recibiendo 01 del chip y comparando.
Entonces si yo estoy recibiendo 53 y me pongo a leer 53 estoy perdido por eso se detenia la rutina. cambie y lo puse a esperar 83 Dec = a 53 hex.:p
Ese era el problema, ahora hay que ver lo de mandar lo que esta en el memo que lo cambia todo.

Un Saludo.

Pues si, pequeño detalle, checa lo que te puse en el post anterior que es para enviar lo que tienes en el Memo1, espero que funcione como lo soñe, :D:D:D

Salud OS

JoseFco 01-04-2008 04:42:25

Ok declare lineaMemo y la otra declaracion.Pero me esta pidiendo declarar esta linea.

Código Delphi [-]
    ComPort.WriteStr(strtoint('$'+Copy(Linea,1,2)));

Me dice que no esta declarada Linea ?

egostar 01-04-2008 04:52:20

Ya corregí el post, checalo, debe ser LineaMemo, habia varios detalles :o

Salud OS

JoseFco 01-04-2008 04:52:42

Eso esta resuelto.

Ahora me da un error:
Código Delphi [-]
  ComPort.WriteStr(strtoint('$'+Copy(LineaMemo,1,2))));

Incompatible Types: " String " and " Integer" ???

egostar 01-04-2008 04:55:51

Cita:

Empezado por JoseFco (Mensaje 276610)
Eso esta resuelto.

Ahora me da un error:
Código Delphi [-]
  ComPort.WriteStr(strtoint('$'+Copy(LineaMemo,1,2))));

Incompatible Types: " String " and " Integer" ???

Si, eso ya lo habia corregido tambien El ComPort.WriteStr no permite enviar enteros, así que lo cambie a Caracter, copia todo el post de nuevo, ya esta corregido.

Salud OS

JoseFco 01-04-2008 05:13:40

Ok ya copilo y rodo sin problemas hasta donde esta la rutina de mandar los bytes al serial. me dio Debugger Exception Notication
raised exception class EconvertError with message "$0" is not a valid integer value.

Como la ves?

egostar 01-04-2008 05:19:31

Cita:

Empezado por JoseFco (Mensaje 276627)
Ok ya copilo y rodo sin problemas hasta donde esta la rutina de mandar los bytes al serial. me dio Debugger Exception Notication
raised exception class EconvertError with message "$0" is not a valid integer value.

Como la ves?

Hola Jose,

Pasame los datos completos del Memo1, tal vez por ahi hay algun problemita, ya es algo tarde y debo salir a casa, mañana lo vemos con calma. ;)

Salud OS

JoseFco 01-04-2008 05:25:43

Asi esta la cosa:

Código Delphi [-]
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, CPort, StdCtrls, ComCtrls;
type
  TForm1 = class(TForm)
    ComPort: TComPort;
    Button1: TButton;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    ProgressBar1: TProgressBar;
    Button2: TButton;
    Button3: TButton;
    Label1: TLabel;
    OpenDialog1: TOpenDialog;
    Memo1: TMemo;
    Label2: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure ComPortRxChar(Sender: TObject; Count: Integer);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
  Cuantos, CuentaB : Integer;
  Contador  : Integer;
  LineaMemo  :  String;
  Count :   Integer;
implementation
{$R *.dfm}
type
 TBuffer = array[$0000..$FFFF] of Byte;
function Insertar(Str: String; var Buffer: TBuffer): String;
var
  i,j,k: Integer;
begin
  Result:= EmptyStr;
  Str:= Trim(Str);
  if Copy(Str,1,1) = ':' then
    if TryStrToInt('$' + Copy(Str,2,2),i) then
      if Length(Str) = ((2*i) + 11) then
        if TryStrToInt('$' + Copy(Str,4,4),j) then
          if TryStrToInt('$' + Copy(Str,8,2),k) then
            if k = 0 then
            begin
              Str:= Copy(Str,10,2*i);
              for k:= j to (j + i - 1) do
              begin
                Buffer[k]:= StrToInt('$' + Copy(Str,1,2));
                Delete(Str,1,2);
              end;
            end;
end;

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     //poner el chip en prog..
ComPort.WriteStr(#2#2);
   Cuantos := 2;
 end;
   2: begin //comando para borrar.
     ComPort.WriteStr(#2#3);
       Cuantos := 3;
   end;
    3: begin //Modo Borrar
    showmessage('Chip Borrado.. OK!')
 end;
    4: begin //poner el chip en prog..
         ComPort.WriteStr(#2#2);
          Cuantos := 5;
      end;
    5: begin // Comando para escribir el chip(06 04 00 00 10 00)
         ComPort.WriteStr(#6#4#0#0#16#0);
            sleep(100);
            Count := 0;   //Agregar esta variable Integer
            LineaMemo := Memo1.Lines[Count]; //Agregar esta variable String (LineaMemo)
              ComPort.WriteStr(Char(strtoint('$'+Copy(LineaMemo,1,2))));
              Delete(LineaMemo,1,3);
           Contador := 2;
     end;
     end;
     end
         else if Str = #2 then begin
         end
           else if Str = #83 then begin
             ComPort.WriteStr(Char(strtoint('$'+Copy(LineaMemo,1,2))));
              Delete(LineaMemo,1,3);
                if LineaMemo = '' then begin
                  LineaMemo := Memo1.Lines[Count+1];
                   end;
              Inc(Contador);

     end;
     end;
 //Aqui comienza el procedimiento para borrar el chip
procedure TForm1.Button1Click(Sender: TObject);
begin
 if not ComPort.Connected then
  ComPort.Open;
 comport.WriteStr(#4#1#0#1);
   Cuantos := 1;
    end;
 //Aqui comienza el procedimiento para escribir el chip
procedure TForm1.Button2Click(Sender: TObject);
begin
 if not ComPort.Connected then
  ComPort.Open;
 comport.WriteStr(#4#1#0#1);
  Cuantos := 4;
end;
procedure TForm1.Button3Click(Sender: TObject);
  var
  i,j: Integer;
  Str: String;
  Buffer: TBuffer;
begin
 if OpenDialog1.Execute then
Label1.caption:=OpenDialog1.FileName;
  Memo1.Clear;
  with TStringList.Create do
  try
    LoadFromFile(Label1.Caption);
    FillChar(Buffer,Sizeof(Buffer),#0);
    for i:= 0 to Count - 1 do
      Insertar(Strings[i],Buffer);
     j:= StrToInt(Label2.caption);
     Str:= EmptyStr;
       for i:= 0 to j -1 do
      begin
   Str:= Str + #32 + IntToHex(Buffer[i],2);
      if ((i+1) mod 16 = 0) then
    begin
        Memo1.Lines.Add(Str);
        Str:= EmptyStr;
      end;
    end;
     if Str <> EmptyStr then
      Memo1.Lines.Add(Str);
  finally
    Free;
  end;
end;
end.

Despues le seguimos, hoy se adelanto un monton:):p;)

Esto esta tomando forma.

Un Saludo y un millon de gracias carnal.

JoseFco 01-04-2008 22:36:35

Alguna idea?

Esta rutina esta trabajando, pero no manda los hex que espero.Solo manda ascii.

Código Delphi [-]
 5: begin // Comando para escribir el chip(06 04 00 00 10 00)
         ComPort.WriteStr(#6#4#0#0#16#0);
            sleep(100);
            ComPort.WriteStr(Memo1.Text[1]);
           Contador := 2;
     end;
     end;
     end
         else if Str = #2 then begin
         end
           else if Str = #83 then begin
                   if contador <= 4096 then begin
                        
                      ComPort.WriteStr(Memo1.Text[Contador]);
                      Inc(Contador);
     end;

Como puedo convertir ascii en hex?
Alguna idea o alguna acternativa?

Un Saludo.

egostar 01-04-2008 23:07:48

Hola amigo Jose

No entiendo lo que quieres, perdon, con lo que ayer vimos deberias de poder transmitir los caracteres, porque al final es eso lo que estan mandando, quiero decir

por ejemplo

Suponiendo que Copy(LineaMemo,1,2) = FE

FE 12 00 AF 75 A0 FD 12 00 AF 75 A0 FB 12 00 AF

Char(strtoint('$'+FE)); = Char(254) = #254

Necesito que postees lo que tienes en el Memo1, pero completo, porque segun lo que yo estoy haciendo no me manda ningúun error....

Salud OS

JoseFco 01-04-2008 23:18:21

Hola egostar.
Aqui esta lo que contiene el memo, en este caso.

00 12 00 72 12 00 7E B4 80 04 80 34 80 F6 75 A0
FE 12 00 AF 75 A0 FD 12 00 AF 75 A0 FB 12 00 AF
75 A0 F7 12 00 AF 75 A0 EF 12 00 AF 75 A0 DF 12
00 AF 75 A0 BF 12 00 AF 75 A0 7F 12 00 AF 80 C4
75 A0 7F 12 00 AF 75 A0 BF 12 00 AF 75 A0 DF 12
00 AF 75 A0 EF 12 00 AF 75 A0 F7 12 00 AF 75 A0
FB 12 00 AF 75 A0 FD 12 00 AF 75 A0 FE 12 00 AF
80 92 75 98 52 75 89 20 75 8D F3 D2 8E 22 30 98
FD C2 98 E5 99 22 C2 B5 89 A0 D2 B4 12 00 AF C2
B4 22 D2 B5 89 A0 D2 B4 12 00 AF C2 B4 22 79 01
11 86 79 38 11 86 79 0C 11 86 79 06 11 86 22 7F
00 7E 00 7D 00 0D BD 50 FC 0E BE 50 F6 0F BF 50
F0 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Son 4096 bytes y tienen que salir asi mismo por el serial port.Hex puro.
Lo ultimo que se hiso ayer da un Debugger Exception.
PD: no puede leer espacios solo los hex 00 to FF.
Un Saludo.

JoseFco 01-04-2008 23:48:07

El problema radica aqui.

Código Delphi [-]
  5: begin // Comando para escribir el chip(06 04 00 00 10 00)
         ComPort.WriteStr(#6#4#0#0#16#0);
            sleep(100);
            Count := 0;   //Agregar esta variable Integer
            LineaMemo := Memo1.Lines[Count]; //Agregar esta variable String (LineaMemo)
              ComPort.WriteStr(Char(strtoint('$'+Copy(LineaMemo,1,2))));             
 Delete(LineaMemo,1,3);           
Contador := 2;     
end;
     end;
     end
         else if Str = #2 then begin
         end
           else if Str = #83 then begin
             ComPort.WriteStr(Char(strtoint('$'+Copy(LineaMemo,1,2))));
              Delete(LineaMemo,1,3);
                if LineaMemo = '' then begin
                  LineaMemo := Memo1.Lines[Count+1];
                   end;
              Inc(Contador);

     end;

Que esta mal? No tengo idea. Pero el programa rueda bien hasta que llega aqui y el CPU se pone enfadado con lo que se le manda a hacer.:confused:

Un Saludo.

egostar 01-04-2008 23:48:25

Cita:

Empezado por JoseFco (Mensaje 276844)
Hola egostar.
Son 4096 bytes y tienen que salir asi mismo por el serial port.Hex puro.
Lo ultimo que se hiso ayer da un Debugger Exception.
PD: no puede leer espacios solo los hex 00 to FF.
Un Saludo.

Bueno, los espacios no los estoy tomando en cuenta, dejame probar algo.

Salud OS

JoseFco 01-04-2008 23:57:38

Lo de los espacios lo decia por lo primero que estabamos haciando ayer, que mandaba ascii y estaba mirando salir "20" .Pero lo que tenemos ahora no manda nada, el programa se tranca justo a partir que le mando a hacer esto.

Código Delphi [-]
 ComPort.WriteStr(Char(strtoint('$'+Copy(LineaMemo,1,2))));

Ya aqui no manda nada y se tranca.

Un Saludo.

JoseFco 02-04-2008 01:45:28

Regresando al anterior procedimiento.

Código Delphi [-]
 5: begin // Comando para escribir el chip(06 04 00 00 10 00)
         ComPort.WriteStr(#6#4#0#0#16#0);
            sleep(100);
            ComPort.WriteStr(Memo1.Text[1]);
               Contador := 2;
      end;
     end;
     end
         else if Str = #2 then begin
         end
           else if Str = #83 then begin
               if contador <= 4096 then begin
                ComPort.WriteStr(Memo1.Text[Contador]);
                Inc(Contador);
     end;
     end;
     end;

Este copila sin problema y rueda bien.Manda los 4096 bytes y recibe los 53h 83d.
Pero manda caracteres ascii, un ejemplo de lo que esta mandando:
Los dos primeros bytes de data en el memo son:

00 12 y lo que sale por el serial port es: 20 30 30 20 31 32 20=espacio 30=0 30=0 aqui "00" otro 20=espacio 31=1 32=2 aqui el "12".

Asi esta la cosa.

Un Saludo.

egostar 02-04-2008 01:50:50

Y si intentas con esto amigo Jose

Código Delphi [-]
       5: begin // Comando para escribir el chip(06 04 00 00 10 00)
          ComPort.WriteStr(#6#4#0#0#16#0);
          sleep(100);
          ComPort.Write(Buffer[1],1);
          Contador := 2;
       end;
   end;

   else if Str = #83 then begin
            if contador <= 4096 then begin
               ComPort.Write(Buffer[Contador],1);
               Inc(Contador);
         end;
     end;
     end;

Salud OS

JoseFco 02-04-2008 02:19:25

Mira esto egostar.

Código Delphi [-]
implementation
{$R *.dfm}
type
 TBuffer = array[$0000..$FFFF] of Byte;
function Insertar(Str: String; var Buffer: TBuffer): String;
var
  i,j,k: Integer;
begin

Estoy cambiando para lo ultimo que mandastes y me da el siguiente error.
Undeclare identifier:'Buffer"

jajajajajajaja esta declarado o no?

Un Saludo.


La franja horaria es GMT +2. Ahora son las 05:07:37.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi