android delphi serial-port delphi-xe5

Puerto serie Delphi XE5 en Android



serial-port delphi-xe5 (1)

He utilizado con éxito Winsoft ComPort para Android para realizar una comunicación USB en serie.

http://www.winsoft.sk/acomport.htm

Mira el código.

unit Main; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Layouts, FMX.Memo, Winsoft.Android.ComPort; type TFormMain = class(TForm) Memo: TMemo; StatusBar: TStatusBar; ToolBar: TToolBar; ButtonOpenClose: TButton; ButtonSettings: TButton; LabelStatus: TLabel; AComPort: TAComPort; Timer: TTimer; procedure ButtonOpenCloseClick(Sender: TObject); procedure AComPortAfterWrite(Sender: TObject; Buffer: Pointer; Length: Integer); procedure TimerTimer(Sender: TObject); procedure AComPortAfterRead(Sender: TObject; Buffer: Pointer; Length: Integer); procedure MemoKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); procedure AComPortError(ComPort: TAComPort; E: EComError; var Action: TComAction); procedure ButtonSettingsClick(Sender: TObject); private { Private declarations } FReadCount: Integer; FWriteCount: Integer; procedure UpdateStatus; public { Public declarations } end; var FormMain: TFormMain; implementation uses Settings; {$R *.fmx} procedure TFormMain.UpdateStatus; begin LabelStatus.Text := ''Read bytes: '' + IntToStr(FReadCount) + '' Write bytes: '' + IntToStr(FWriteCount); end; procedure TFormMain.AComPortAfterRead(Sender: TObject; Buffer: Pointer; Length: Integer); begin FReadCount := FReadCount + Length; UpdateStatus; end; procedure TFormMain.AComPortAfterWrite(Sender: TObject; Buffer: Pointer; Length: Integer); begin FWriteCount := FWriteCount + Length; UpdateStatus; end; procedure TFormMain.AComPortError(ComPort: TAComPort; E: EComError; var Action: TComAction); begin ShowMessage(''Error '' + IntToStr(E.ErrorCode) + '': '' + E.Message); Action := caAbort; end; procedure TFormMain.ButtonOpenCloseClick(Sender: TObject); begin AComPort.Active := not AComPort.Active; Timer.Enabled := AComPort.Active; Memo.Enabled := AComPort.Active; ButtonSettings.Enabled := not AComPort.Active; if AComPort.Active then ButtonOpenClose.Text := ''Close'' else ButtonOpenClose.Text := ''Open''; end; procedure TFormMain.ButtonSettingsClick(Sender: TObject); begin FormSettings.Show; end; procedure TFormMain.MemoKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); begin AComPort.WriteByte(Ord(KeyChar)); end; procedure TFormMain.TimerTimer(Sender: TObject); var Text: string; begin Text := AComPort.ReadUtf8; if Text <> '''' then Memo.Text := Memo.Text + Text; end; end.

En las propiedades del componente, debe incluir las características esenciales que crean su comunicación en el puerto serie.

Tales como: nombre del dispositivo, databits, baudrate, paridad y bits de parada , por ejemplo.

Alguien tiene alguna idea de cómo acceder al puerto serie en Android con delphi XE5? Estoy usando una Cubieboard con Android 4.1