Ver Mensaje Individual
  #1  
Antiguo 06-11-2010
Avatar de JoysticK
JoysticK JoysticK is offline
Miembro
 
Registrado: abr 2004
Posts: 68
Reputación: 21
JoysticK Va por buen camino
Cool Componente TApdComport en Delphi 2010

Estoy investigando algún componente para comunicación serie mediante delphi 2010 por ahora me he descargado el paquete AsyncPro, he instalado los componentes pero ya he recibido el primer error al intentar compilar el programa ejemplo Excom0, para variar con las char y ansi char...

Código:
{**********************Description************************}
{*    TApdComPort with an OnTriggerAvail handler.        *}
{*********************************************************}

unit Excom0;

interface

uses
  WinTypes, WinProcs, SysUtils, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, AdPort, OoMisc;

type
  TForm1 = class(TForm)
    ApdComPort1: TApdComPort;
    Test: TButton;
    Memo1: TMemo;
    procedure TestClick(Sender: TObject);
    procedure ApdComPort1TriggerAvail(CP: TObject; Count: Word);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.TestClick(Sender: TObject);
  {TestClick button click - Send output}
begin
  ApdComPort1.OutPut := 'ATZ'^M;
end;

procedure TForm1.ApdComPort1TriggerAvail(CP: TObject; Count: Word);
  {Event OnTriggerAvail - Example how OnTriggerAvail works} 
var
  I : Word;
  C : Char;
  S : String;
begin
  S := '';
  for I := 1 to Count do begin
    C := ApdComPort1.GetChar;
    case C of
      #0..#31 : {Don't display} ;
      else S := S + C;
    end;
  end;
  ShowMessage('Got an OnTriggerAvail event for: ' + S);
  //Memo1.Text := Memo1.Text + S;
end;

end.
El error de compilación me lo marca en la linea:

Código:
    C := ApdComPort1.GetChar;
Con el error
Cita:
[DCC Error] EXCOM0.PAS(77): E2010 Incompatible types: 'Char' and 'AnsiChar'
He probado a cambiar la definicion de la variable C a
Código:
  C : AnsiChar;
El ejemplo compila pero los datos que recibe del puerto serie no tienen ningun sentido cuando en el hiperterminal si recibo texto coerente

Cita:
0fÌƘ†˜Ì3€†àžfžÿÀÌ€Ìfà†øfàæà~3xcü`ffÀøfÌÀžfãæà†~ÀÌxæxÏ€˜fÃü†~Àxf𞘞<`?˜ì˜àœƒf̆ž˜€˜ààÀàÀ˜à˜30ž€fxóð Â~ÀÌxóž€0fáü†~ÀxxÏ€˜žœ`?˜Ìüƒf̆ž˜˜àÀàÀ˜àà˜030`Ï€†fÃæà†~ÀÌxÌóž€0fxÿÃ~ÀxÌxÏ€˜ž<`Ÿ˜æ˜xÏ€f䆞˜˜àÀàÀ˜à˜à ˜030¼
¿ alguna idea ?
__________________
Borland Delphi XE2 // Interbase Server
Responder Con Cita